title: CakePHP 3 slow json responses, why?
body: <p>I have something very simple in an API I've built with CakePHP 3. It's a ping endpoint that just returns a simple little response</p>
  
  <pre><code>{"success":true,"message":"Thanks for saying hello. Everything looks good so far."}
  </code></pre>
  
  <p>When I use the following code that uses CakePHPs extension parsing for JSON I get the following benchmark.</p>
  
  <pre><code>public function ping(){
      $message = 'Thanks for saying hello. Everything looks good so far.';
      $this-&gt;set('message', $message);
      $this-&gt;set('success', true);
      $this-&gt;set('_serialize', true);
  }
  </code></pre>
  
  <p>Benchmark:</p>
  
  <pre><code>Server Software:        Apache/2.4.18
  Server Hostname:        app.local
  Server Port:            80
  
  Document Path:          /publisher/v3.0/.json
  Document Length:        83 bytes
  
  Concurrency Level:      10
  Time taken for tests:   10.034 seconds
  Complete requests:      12
  Failed requests:        0
  Total transferred:      4760 bytes
  HTML transferred:       1660 bytes
  Requests per second:    1.20 [#/sec] (mean)
  Time per request:       8361.339 [ms] (mean)
  Time per request:       836.134 [ms] (mean, across all concurrent requests)
  Transfer rate:          0.46 [Kbytes/sec] received
  </code></pre>
  
  <p>And I remove extension parsing and do the following code...</p>
  
  <pre><code>public function ping(){
      $message = 'Thanks for saying hello. Everything looks good so far.';
      echo json_encode(['success'=&gt;true, 'message'=&gt; $message]); 
      exit(0);
  }
  </code></pre>
  
  <p>Benchmark:</p>
  
  <pre><code>Server Software:        Apache/2.4.18
  Server Hostname:        app.local
  Server Port:            80
  
  Document Path:          /publisher/v3.0/
  Document Length:        83 bytes
  
  Concurrency Level:      10
  Time taken for tests:   10.000 seconds
  Complete requests:      5895
  Failed requests:        0
  Total transferred:      1733130 bytes
  HTML transferred:       489285 bytes
  Requests per second:    589.49 [#/sec] (mean)
  Time per request:       16.964 [ms] (mean)
  Time per request:       1.696 [ms] (mean, across all concurrent requests)
  Transfer rate:          169.25 [Kbytes/sec] received
  </code></pre>
  
  <p>1.2 requests per second is paltry compared to 589 requests per second. How can this be? Have I done something wrong? I used apache benchmark with 10 concurrent requests over 10 seconds. I can't continue with using Cake 3 if its this slow... I'm better off using Phalcon, CI, Slim, or rolling my own at that point. Please tell me I'm doing something wrong...</p>