http response is unavailable
svatok13 opened this issue · 1 comments
First of all, thank`s for your work.
I have some app, which is only getting some data from database(MySQL) and returning json response. Also I am using redis caching. I am testing my app performance by bombardier. And under pressure my app started to return 500, and log some warnings, like
http response is unavailable (maybe it has been ended or detached)
./bombardier-linux-amd64 -c 10 -d 25s --fasthttp http://localhost:1013/news
Bombarding http://localhost:1013/news for 25s using 10 connection(s)
[=============================================================================================] 25s
Done!
Statistics Avg Stdev Max
Reqs/sec 69.94 82.57 825.46
Latency 143.69ms 284.65ms 3.21s
HTTP codes:
1xx - 0, 2xx - 1475, 3xx - 0, 4xx - 0, 5xx - 285
others - 0
Throughput: 609.71KB/s
Action code example:
public function __invoke(TagAwareCacheInterface $cache, int $newsCacheTtl): JsonResponse
{
return $cache->get('news_list', function (ItemInterface $item) use ($newsCacheTtl) {
$item->expiresAfter($newsCacheTtl);
$news = $this->repository->findNews();
$item->tag('news_list');
return new JsonResponse( $this->serializer->serialize([
'data' => $news,
'pagination_info' => [
'limit' => (int) $requestData['limit'],
'offset' => (int) $requestData['offset'],
'count' => $this->repository->getNewsCountByParams($requestData),
],
], 'json'), JsonResponse::HTTP_OK, [], true);
});
}
Also I figure out, that under pressure my app started to throw exception
Circular reference detected for service "App\Route\GetNewsAction", path: "App\Route\GetNewsAction -> App\Route\GetNewsAction
which seem weird, because if there was some circular reference, my app wouldn`t even start.
What am I doing wrong?
Swoole config
swoole:
http_server:
port: 80
running_mode: reactor
hmr: off
services:
debug_handler: true
entity_manager_handler: true
static:
public_dir: "%kernel.project_dir%/public"
strategy: default
settings:
reactor_count: 2
worker_count: 4
worker_max_request: 1024
- OS: Linux
- PHP Version:7.4.12
- Swoole Version: 4.5.10
- Symfony Version: 4.4.12
- Running in docker: Yes
Logs
Symfony/Swoole Logs
15:25:02 WARNING [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]