{"id":457982,"date":"2025-04-29T09:29:40","date_gmt":"2025-04-29T09:29:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=457982"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=457982","title":{"rendered":"<span>CRUD \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432 \u0438 \u043f\u0443\u043b\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0441 PostgreSQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/www.php.net\/manual\/en\/language.fibers.php\" rel=\"noopener noreferrer nofollow\">\u0444\u0430\u0439\u0431\u0435\u0440\u044b<\/a> \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435(\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.pgsql.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PostreSQL<\/a>. \u0412\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u0441\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0442\u0435\u0439: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/866254\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432;<\/a>  <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/895580\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432. \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f;<\/a>  <\/p>\n<\/li>\n<\/ul>\n<p>\u0421 \u043d\u0438\u043c\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f (\u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e), \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u044d\u0442\u043e HTTP-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 PHP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 HTTP-\u043f\u043e\u0440\u0442, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u044b, \u0434\u0435\u043b\u0430\u044f \u044d\u0442\u043e \u0431\u0435\u0437 \u043f\u043e\u043c\u043e\u0449\u0438 Nginx, Apache \u0438 PHP FPM. \u0414\u043e\u0441\u0442\u0438\u0447\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0435\u043c\u0443 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.ev.php\" rel=\"noopener noreferrer nofollow\">ev<\/a> (\u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432, \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/function.socket-select.php\" rel=\"noopener noreferrer nofollow\"><code>socket_select()<\/code><\/a>) \u0438 \u0444\u0430\u0439\u0431\u0435\u0440\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c <a href=\"https:\/\/www.postgresql.org\/\" rel=\"noopener noreferrer nofollow\">PostreSQL<\/a>.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/file?branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0432 \u0432\u0435\u0442\u043a\u0435 aircraft<\/a>. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 CRUD API \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u041e\u0431\u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041f\u0435\u0440\u0432\u044b\u0439 (\u043f\u043e\u0440\u0442 8085) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432, \u0432 \u0432\u0442\u043e\u0440\u043e\u0439 (\u043f\u043e\u0440\u0442 8086) \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 Nginx+PHP FPM. \u041e\u0431\u0430 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 <code>aircraft<\/code> \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 PostgreSQL. \u041a\u043e\u0434 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 Docker-compose \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430.<\/p>\n<h2>\u041a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u044b\u0439 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440 (\u043f\u043e\u0440\u0442 8085) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP CLI, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0444\u0430\u0439\u043b <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob\/?file=docker-compose.yml&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">docker-compose.yml<\/a>:<\/p>\n<pre><code class=\"yaml\">services:     php:         command: php -f \/app\/bin\/server.php<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>\/sleep<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FController%2FSleepController.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">class SleepController {     private Db $db;      public function __construct(Db $db)     {         $this-&gt;db = $db;     }      public function __invoke(ServerRequestInterface $request, FiberedHandler $fiberedHandler): ResponseInterface     {         $affectedRows = $this-&gt;db-&gt;execute($fiberedHandler, 'SELECT pg_sleep(1)');         $rows = $this-&gt;db-&gt;query($fiberedHandler, 'SELECT gen_random_uuid() AS uuid');         if (count($rows) !== 1 || !isset($rows[0]['uuid'])) {             throw new LogicException('Something went wrong.');         }         $uuid = $rows[0]['uuid'];          return new TextResponse(\"Hello from Sleep request handler! Affected rows: $affectedRows. Generated uuid: $uuid\");     } }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0431\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0442\u043e \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430, \u0441\u043a\u0430\u0436\u0435\u043c, 10 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 10 \u0441\u0435\u043a\u0443\u043d\u0434, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 PHP CLI \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0437\u0430 2+ \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c <a href=\"https:\/\/httpd.apache.org\/docs\/current\/programs\/ab.html\" rel=\"noopener noreferrer nofollow\">\u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 ab<\/a>:<\/p>\n<pre><code>$ ab -c 10 -n 10 http:\/\/localhost:8085\/sleep  Concurrency Level:      10 Time taken for tests:   2.029 seconds Complete requests:      10 Failed requests:        0 Total transferred:      1640 bytes HTML transferred:       1040 bytes Requests per second:    4.93 [#\/sec] (mean) Time per request:       2028.604 [ms] (mean) Time per request:       202.860 [ms] (mean, across all concurrent requests) Transfer rate:          0.79 [Kbytes\/sec] received<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0441\u043e\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 PHP \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c <code>pg_sleep(1)<\/code> \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c PostgreSQL. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 Postgres \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0430\u0439\u0431\u0435\u0440\u044b, \u0446\u0438\u043a\u043b \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u043e\u0433\u043e HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435<\/h2>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f, \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 4-\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0447\u0442\u0435\u043d\u0438\u0435, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435) \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/jmeter.apache.org\/\" rel=\"noopener noreferrer nofollow\">JMeter<\/a>. 50 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e 200 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u0430\u0436\u0434\u044b\u0439, \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/625\/72a\/7b0\/62572a7b02c38f550ef8a6b16e3c8d9c.png\" alt=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JMeter\" title=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JMeter\" width=\"296\" height=\"146\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/625\/72a\/7b0\/62572a7b02c38f550ef8a6b16e3c8d9c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/625\/72a\/7b0\/62572a7b02c38f550ef8a6b16e3c8d9c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JMeter<\/figcaption><\/div>\n<\/figure>\n<p><a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=jmeter%2Ffabio.jmx&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u0424\u0430\u0439\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 JMeter<\/a> \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a26\/537\/ceb\/a26537cebdf20beacd9e8ebd7bd1858f.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432 (\u043f\u043e\u0440\u0442 8085)\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432 (\u043f\u043e\u0440\u0442 8085)\" width=\"1475\" height=\"536\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/a26\/537\/ceb\/a26537cebdf20beacd9e8ebd7bd1858f.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a26\/537\/ceb\/a26537cebdf20beacd9e8ebd7bd1858f.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432 (\u043f\u043e\u0440\u0442 8085)<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2c0\/5e7\/d8b\/2c05e7d8bc9ac8515f1df40246ed7c29.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM (\u043f\u043e\u0440\u0442 8086)\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM (\u043f\u043e\u0440\u0442 8086)\" width=\"1475\" height=\"525\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/2c0\/5e7\/d8b\/2c05e7d8bc9ac8515f1df40246ed7c29.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2c0\/5e7\/d8b\/2c05e7d8bc9ac8515f1df40246ed7c29.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM (\u043f\u043e\u0440\u0442 8086)<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432: ~58 \u043a\u0440\u0443\u0434\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u0440\u043e\u0442\u0438\u0432 16 \u043a\u0440\u0443\u0434\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/github.com\/google\/cadvisor?ysclid=m9rksakmje459875550\" rel=\"noopener noreferrer nofollow\">cAdvisor<\/a>, <a href=\"https:\/\/prometheus.io\/\" rel=\"noopener noreferrer nofollow\">Prometheus <\/a>\u0438 <a href=\"https:\/\/grafana.com\/\" rel=\"noopener noreferrer nofollow\">Grafana<\/a> \u0431\u044b\u043b \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0442\u0440\u0451\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5b4\/ff8\/226\/5b4ff82262d25c10ddb354accbaa1ce5.png\" alt=\"\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0417\u0435\u043b\u0451\u043d\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d CRUD \u043d\u0430 \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u0445, \u0436\u0451\u043b\u0442\u044b\u043c - PHP FPM\" title=\"\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0417\u0435\u043b\u0451\u043d\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d CRUD \u043d\u0430 \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u0445, \u0436\u0451\u043b\u0442\u044b\u043c - PHP FPM\" width=\"835\" height=\"596\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/5b4\/ff8\/226\/5b4ff82262d25c10ddb354accbaa1ce5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5b4\/ff8\/226\/5b4ff82262d25c10ddb354accbaa1ce5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0417\u0435\u043b\u0451\u043d\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d CRUD \u043d\u0430 \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u0445, \u0436\u0451\u043b\u0442\u044b\u043c &#8212; PHP FPM<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0443\u043b\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u0411\u0414 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u0435\u043b\u0430\u044f \u0442\u0443 \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 3 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u043d\u0430 1 \u044f\u0434\u0440\u0435 \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, FPM \u043d\u0430\u0447\u043d\u0451\u0442 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440, \u043e\u0434\u043d\u0430\u043a\u043e \u0438 \u0434\u043b\u044f \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0437\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439. \u0422\u0430\u043a \u0447\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043d\u0430 1 \u044f\u0434\u0440\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438, \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430.<\/p>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c CRUD, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>\u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u043d\u0430 \u0431\u0430\u0437\u0435 <a href=\"https:\/\/github.com\/nikic\/FastRoute\" rel=\"noopener noreferrer nofollow\">FastRoute<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/symfony\/dependency-injection\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0439\u0441\u043a\u0438\u0439 DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/laminas\/laminas-httphandlerrunner\" rel=\"noopener noreferrer nofollow\">laminas\/laminas-httphandlerrunner<\/a> \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438 PSR7 Response \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/doctrine\/migrations\" rel=\"noopener noreferrer nofollow\">\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 Doctrine<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/symfony\/validator\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0439\u0441\u043a\u0438\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440<\/a> \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e CRUD-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432;<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0435 \u0431\u0443\u0434\u0443 \u043d\u0430 \u043d\u0438\u0445 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u043e\u0434 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0432 \u0447\u0430\u0441\u0442\u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0445\u043e\u0436 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0430\u0439\u043b <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FDb%2FAsyncDb.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">src\/Db\/AsyncDb.php<\/a>. \u0412\u043e\u0442 \u0432 \u0447\u0451\u043c \u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"php\">private function sendQuery(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket,     string $query,     array $params ): void {     if (!pg_send_query_params($connection, $query, $params)) {         throw new DbException('Error while sending the query.');     }     $start = time();     $readyTo = null;     while (true) {         if ($readyTo === FiberedHandler::SOCKET_READY_TO_READ) {             App::debugFiber($fiberedHandler, 'Consuming query result.');             if (!pg_consume_input($connection)) {                 throw new DbException('Error while consuming the query result.');             }         }         $flush = pg_flush($connection);         App::debugFiber($fiberedHandler, 'Flushing resulted with: %d', $flush);         if ($flush === false) {             throw new DbException('Error while sending the query.');         } elseif ($flush === true) {             App::debugFiber($fiberedHandler, 'Flushing has been finished successfully.');             break;         }         $fiberedHandler-&gt;addReadSocket($connectionSocket);         $fiberedHandler-&gt;addWriteSocket($connectionSocket);         $readyTo = $fiberedHandler-&gt;suspend();         if ($fiberedHandler-&gt;isTimeoutReached($start)) {             throw new DbException('Connection timed out while executing a database query.');         }     } }<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <a href=\"https:\/\/www.php.net\/manual\/en\/book.pgsql.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PgSQL<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435, \u0430 \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432, \u043d\u0435 \u0436\u0434\u0451\u043c, \u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432. \u0422\u043e\u0447\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0411\u0414 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>pg_send_query_params()<\/code>  \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u0430 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u0431\u0435\u0440) \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c <code>Fiber::suspend()<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0445\u043e\u0436\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>pg_consume_input()<\/code>, <code>pg_connection_busy()<\/code> \u0438 <code>pg_get_result()<\/code>. \u042d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/libpq-async.html#LIBPQ-PQCONSUMEINPUT\" rel=\"noopener noreferrer nofollow\">PostgreSQL libpq<\/a>. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PosgreSQL \u0434\u043b\u044f PHP \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430, \u043d\u043e, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u044d\u0442\u043e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpq, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043d\u0430\u0431\u0436\u0435\u043d\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"php\">private function receiveQueryResultAndFetchAllRows(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket ): array {     $result = $this-&gt;receiveQueryResult($fiberedHandler, $connection, $connectionSocket);     $rows = pg_fetch_all($result);     if ($rows === false) {         throw new DbException('Error while extracting the data from the query result.');     }     if (!pg_free_result($result)) {         throw new DbException('Error while freeing the query result.');     }      return $rows; }  private function receiveQueryResult(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket ): Result {     $start = time();     while (true) {         App::debugFiber($fiberedHandler, 'Consuming query result.');         if (!pg_consume_input($connection)) {             throw new DbException('Error while consuming the query result.');         }         if (!pg_connection_busy($connection)) {             App::debugFiber($fiberedHandler, 'The query result is ready. Going to read it immediately.');             break;         }         App::debugFiber($fiberedHandler, 'The connection is busy. Waiting for the data to read.');         $fiberedHandler-&gt;addReadSocket($connectionSocket);         $fiberedHandler-&gt;suspend();         if ($fiberedHandler-&gt;isTimeoutReached($start)) {             throw new DbException('Connection timed out while executing a database query.');         }     }     $result = pg_get_result($connection);     if ($result === false) {         throw new DbException('Error while getting the query result.');     }     $errorMessage = pg_result_error($result);     if (!empty($errorMessage)) {         $sqlState = pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);         if (is_numeric($sqlState)) {             $code = (int)$sqlState;         } else {             $code = 0;         }         throw new DbException(sprintf('Error while getting the query result: %s %s', $sqlState, $errorMessage), $code);     }      return $result; }<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414. \u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0436\u0438\u0432\u0443\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0437\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0431\u044b\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/habr.com\/ru\/articles\/194142\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u043b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439<\/a>. \u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0443\u043b\u0430 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0443\u043b \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">public function query(FiberedHandler $fiberedHandler, string $query, array $params = []): array {     if (str_contains($query, ';')) {         throw new InvalidArgumentException('Multiple queries are unsupported.');     }     try {         $connection = $this-&gt;connectionPool-&gt;obtainConnection($fiberedHandler);     } catch (DbException $e) {         App::debugFiber($fiberedHandler, 'Error getting a database connection instance.');         throw $e;     }     try {         $connectionSocket = $this-&gt;extractSocket($connection);         $this-&gt;sendQuery($fiberedHandler, $connection, $connectionSocket, $query, $params);         $rows = $this-&gt;receiveQueryResultAndFetchAllRows($fiberedHandler, $connection, $connectionSocket);         $this-&gt;connectionPool-&gt;freeConnection($connection); \/\/DO NOT FORGET TO RETURN THE CONNECTION BACK TO THE POOL!!!     } catch (DbException $e) {         App::debugFiber($fiberedHandler, 'DbException occurred. Going to close the database connection: %s', $e-&gt;getMessage());         $this-&gt;connectionPool-&gt;closeConnection($connection);         throw $e;     }      return $rows; }<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0441\u0430\u043c\u043e\u0433\u043e <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FDb%2FConnectionPool.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u043b\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439<\/a> \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442, \u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php  class ConnectionPool {     \/** @var Connection[] *\/     private array $freeConnections = [];      \/** @var array&lt;int, Connection&gt;*\/     private array $obtainedConnections = [];      \/**      * @throws DbException      *\/     public function obtainConnection(FiberedHandler $fiberedHandler): Connection     {         if (!empty($this-&gt;freeConnections)) {             \/** @var Connection $connection *\/             $connection = array_shift($this-&gt;freeConnections);             $connectionStatus = pg_connection_status($connection);             App::debugFiber($fiberedHandler, 'A free connection found. Status: %d. Pid: %d', $connectionStatus, pg_get_pid($connection));             if ($connectionStatus !== PGSQL_CONNECTION_OK) {                 pg_close($connection);                 App::debugFiber($fiberedHandler, 'Postgresql connection is not ok: %d', $connectionStatus);                 $connection = $this-&gt;initConnection($fiberedHandler);             }         } else {             App::debugFiber($fiberedHandler, 'There is no free connection. Will try to init a new one.');             $connection = $this-&gt;initConnection($fiberedHandler);         }         $this-&gt;obtainedConnections[spl_object_id($connection)] = $connection;          return $connection;     }      public function freeConnection(Connection $connection): void     {         unset($this-&gt;obtainedConnections[spl_object_id($connection)]);         $this-&gt;freeConnections[] = $connection;     }      public function closeConnection(Connection $connection): void     {         unset($this-&gt;obtainedConnections[spl_object_id($connection)]);         pg_close($connection);     }       \/**      * @throws DbException      *\/     public function initConnection(FiberedHandler $fiberedHandler): Connection     {         App::debugFiber($fiberedHandler, 'Postgresql connection initialization started.');         $start = time();         $connection = pg_connect(getenv('PG_CONN_STR'), PGSQL_CONNECT_ASYNC | PGSQL_CONNECT_FORCE_NEW);         if ($connection === false) {             $lastError = pg_last_error();             App::debugFiber($fiberedHandler, 'Postgresql connect error: %s', $lastError);             throw new DbException(sprintf(\"Postgresql connect error: %s\", $lastError));         }         while (true) {             $connectionStatus = pg_connect_poll($connection);             App::debugFiber($fiberedHandler, 'Postgresql connection status: %d', $connectionStatus);             if (in_array($connectionStatus, [PGSQL_POLLING_READING, PGSQL_POLLING_WRITING])) {                 $pgSocket = Sock::fromStream(pg_socket($connection)); \/\/let's see what will happen using this bunch of function calls                 if ($connectionStatus === PGSQL_POLLING_READING) {                     $fiberedHandler-&gt;addReadSocket($pgSocket);                 } else {                     $fiberedHandler-&gt;addWriteSocket($pgSocket);                 }                 App::debugFiber($fiberedHandler, 'Postgresql connection is not ready yet. Suspending fiber.');                 Fiber::suspend();                 if ($fiberedHandler-&gt;isTimeoutReached($start)) {                     App::debugFiber($fiberedHandler, 'Connection timed out while connecting to Postgresql. Reason: %s', pg_last_error($connection));                     throw new DbException('Connection timed out while connecting to Postgresql.');                 }                 continue;             }             if ($connectionStatus === PGSQL_POLLING_FAILED) {                 $lastError = pg_last_error($connection);                 App::debugFiber($fiberedHandler, 'Postgresql connect error: %s', $lastError);                 throw new DbException(sprintf(\"Postgresql connect error: %s\", $lastError));             } elseif ($connectionStatus === PGSQL_POLLING_OK) {                 App::debugFiber($fiberedHandler, 'Postgresql connection initialized. Connection pid: %s', pg_get_pid($connection));                 break;             } else {                 App::debugFiber($fiberedHandler, 'Unknown Postgresql connection state: %s', $connectionStatus);                 throw new DbException('Unknown Postgresql connection state.');             }         }          return $connection;     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0441 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0413\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>pg_connect_poll()<\/code>, \u0446\u0438\u043a\u043b \u0438 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u0431\u0435\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>pg_connection_status()<\/code>, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FService%2FAircraftService.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 CRUD. \u041f\u0440\u043e\u0448\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043d\u0435 \u043c\u0435\u0441\u0442\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u043c \u0441\u043b\u043e\u0435, \u043d\u043e \u0432 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0435\u0433\u043e \u043a\u043e\u0434 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u043c\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u043d\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 <code>$fiberedHandler<\/code>\u0432 \u043d\u0438\u0436\u0435\u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0441\u043b\u043e\u0439. <\/p>\n<pre><code class=\"php\">public function add(AircraftDto $dto, FiberedHandler $fiberedHandler): void {     try {         $insertedRows = $this-&gt;db-&gt;execute(             $fiberedHandler,             'INSERT INTO aircraft(                 number,                  title,                  serial_number,                  assembly_date,                  added_at             ) VALUES($1, $2, $3, $4, $5)',             [                 $dto-&gt;number,                 $dto-&gt;title,                 $dto-&gt;serialNumber,                 $dto-&gt;assemblyDate-&gt;format('Y-m-d'),                 $dto-&gt;addedAt-&gt;format('Y-m-d')             ]         );         if ($insertedRows !== 1) {             throw new DomainException('Error while adding new aircraft.');         }     } catch (DbException $e) {         if ($e-&gt;isDuplicateKey()) {             throw new DuplicateEntityException('This aircraft has been already added.', $e-&gt;getCode(), $e);         }         throw new DomainException('Something went wrong.', $e-&gt;getCode(), $e);     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u043d\u0435\u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>$fiberedHandler<\/code>, \u0447\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 PHP FPM \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430: \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u043a\u043e\u0434 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0431\u0430\u0437\u0435 FastRoute \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0432 \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0430 PHP FPM \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u043e\u0431\u044a\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430.  \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u043b\u0438\u0431\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u043b\u0438\u0431\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0451\u0433\u043e\u043a \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043d\u0430 \u043d\u0451\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0411\u0414 \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e(\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e) \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0434\u0435\u043b\u0430\u044e\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435(\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435) \u0432\u044b\u0437\u043e\u0432\u044b, \u043d\u043e \u0441 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0422\u0430\u043a\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u044f\u0434\u0440\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0436\u0434\u0430\u0442\u044c. \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e libev (<a href=\"https:\/\/www.php.net\/manual\/ru\/book.ev.php\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f  ev<\/a>) , \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 FPM &#8212; \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u043e\u043a\u0435\u0442\u043e\u0432, \u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u043e\u0434\u0445\u043e\u0434 <em>&#171;\u043e\u0434\u0438\u043d \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043b\u0438 \u043f\u043e\u0442\u043e\u043a \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430&#187;<\/em> \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0438 \u043f\u043e\u0442\u043e\u043a\u0438 \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u0442\u044c \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438, \u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u043c\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0431\u0430\u0433\u043e\u0432, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0445 \u0438\u0437-\u0437\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 thread-safety \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043e\u0431\u044a\u0451\u043c\u043d\u043e\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0439 HTML \u0438\u043b\u0438 XML, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Twig-\u0448\u0430\u0431\u043b\u043e\u043d), \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u0434\u0430\u043d\u0438\u0439: \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0449\u0435\u043c\u0443 \u0432\u043e\u0440\u043a\u0435\u0440\u0443 \u0438 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0437\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u042f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u043b\u044f MySQL \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0414\u0440\u0430\u0439\u0432\u0435\u0440 <a href=\"https:\/\/www.php.net\/manual\/en\/book.mysqli.php\" rel=\"noopener noreferrer nofollow\">mysqli<\/a> \u0445\u043e\u0442\u044c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <a href=\"https:\/\/www.php.net\/manual\/en\/mysqli.poll.php\" rel=\"noopener noreferrer nofollow\">\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a>, \u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.php.net\/manual\/en\/function.pg-socket.php\" rel=\"noopener noreferrer nofollow\"><code>pg_socket()<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u0441\u043e\u043a\u0435\u0442\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414. \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0434\u0435\u044f\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f.<\/p>\n<p><em>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0425\u0430\u0431\u0440\u0430;)<\/em><\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio?branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0432\u0435\u0442\u043a\u0430 aircraft;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.php.net\/manual\/ru\/language.fibers.php\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u043e \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u043c;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.php.net\/manual\/ru\/book.ev.php\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e ev;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.postgresql.org\/docs\/current\/libpq-async.html#LIBPQ-PQCONSUMEINPUT\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 libpq, \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.php.net\/manual\/en\/book.pgsql.php\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 PgSQL \u0434\u043b\u044f PHP;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/895580\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f: \u041f\u0440\u0438\u043c\u0435\u0440 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432. \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.piter.com\/collection\/bestsellery-manning\/product\/grokaem-konkurentnost?ysclid=m9s70nkos0138433166\" rel=\"noopener noreferrer nofollow\">\u041a\u043d\u0438\u0433\u0430 &#171;\u0413\u0440\u043e\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c&#187;;<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/902572\/\"> https:\/\/habr.com\/ru\/articles\/902572\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/www.php.net\/manual\/en\/language.fibers.php\" rel=\"noopener noreferrer nofollow\">\u0444\u0430\u0439\u0431\u0435\u0440\u044b<\/a> \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435(\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.pgsql.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PostreSQL<\/a>. \u0412\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u0441\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0442\u0435\u0439: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/866254\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432;<\/a>  <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/895580\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432. \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f;<\/a>  <\/p>\n<\/li>\n<\/ul>\n<p>\u0421 \u043d\u0438\u043c\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f (\u043d\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e), \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u044d\u0442\u043e HTTP-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 PHP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0443\u0448\u0430\u0435\u0442 HTTP-\u043f\u043e\u0440\u0442, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u044b, \u0434\u0435\u043b\u0430\u044f \u044d\u0442\u043e \u0431\u0435\u0437 \u043f\u043e\u043c\u043e\u0449\u0438 Nginx, Apache \u0438 PHP FPM. \u0414\u043e\u0441\u0442\u0438\u0447\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0435\u043c\u0443 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.ev.php\" rel=\"noopener noreferrer nofollow\">ev<\/a> (\u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432, \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.php.net\/manual\/ru\/function.socket-select.php\" rel=\"noopener noreferrer nofollow\"><code>socket_select()<\/code><\/a>) \u0438 \u0444\u0430\u0439\u0431\u0435\u0440\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c <a href=\"https:\/\/www.postgresql.org\/\" rel=\"noopener noreferrer nofollow\">PostreSQL<\/a>.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/file?branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0432 \u0432\u0435\u0442\u043a\u0435 aircraft<\/a>. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 CRUD API \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u041e\u0431\u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041f\u0435\u0440\u0432\u044b\u0439 (\u043f\u043e\u0440\u0442 8085) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432, \u0432 \u0432\u0442\u043e\u0440\u043e\u0439 (\u043f\u043e\u0440\u0442 8086) \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 Nginx+PHP FPM. \u041e\u0431\u0430 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 <code>aircraft<\/code> \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 PostgreSQL. \u041a\u043e\u0434 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 Docker-compose \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430.<\/p>\n<h2>\u041a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u044b\u0439 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440 (\u043f\u043e\u0440\u0442 8085) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP CLI, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0444\u0430\u0439\u043b <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob\/?file=docker-compose.yml&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">docker-compose.yml<\/a>:<\/p>\n<pre><code class=\"yaml\">services:     php:         command: php -f \/app\/bin\/server.php<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>\/sleep<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FController%2FSleepController.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/a> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">class SleepController {     private Db $db;      public function __construct(Db $db)     {         $this-&gt;db = $db;     }      public function __invoke(ServerRequestInterface $request, FiberedHandler $fiberedHandler): ResponseInterface     {         $affectedRows = $this-&gt;db-&gt;execute($fiberedHandler, 'SELECT pg_sleep(1)');         $rows = $this-&gt;db-&gt;query($fiberedHandler, 'SELECT gen_random_uuid() AS uuid');         if (count($rows) !== 1 || !isset($rows[0]['uuid'])) {             throw new LogicException('Something went wrong.');         }         $uuid = $rows[0]['uuid'];          return new TextResponse(\"Hello from Sleep request handler! Affected rows: $affectedRows. Generated uuid: $uuid\");     } }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0431\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0442\u043e \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430, \u0441\u043a\u0430\u0436\u0435\u043c, 10 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 10 \u0441\u0435\u043a\u0443\u043d\u0434, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 PHP CLI \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0437\u0430 2+ \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c <a href=\"https:\/\/httpd.apache.org\/docs\/current\/programs\/ab.html\" rel=\"noopener noreferrer nofollow\">\u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 ab<\/a>:<\/p>\n<pre><code>$ ab -c 10 -n 10 http:\/\/localhost:8085\/sleep  Concurrency Level:      10 Time taken for tests:   2.029 seconds Complete requests:      10 Failed requests:        0 Total transferred:      1640 bytes HTML transferred:       1040 bytes Requests per second:    4.93 [#\/sec] (mean) Time per request:       2028.604 [ms] (mean) Time per request:       202.860 [ms] (mean, across all concurrent requests) Transfer rate:          0.79 [Kbytes\/sec] received<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0441\u043e\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 PHP \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c <code>pg_sleep(1)<\/code> \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c PostgreSQL. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 Postgres \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0430\u0439\u0431\u0435\u0440\u044b, \u0446\u0438\u043a\u043b \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u043e\u0433\u043e HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435<\/h2>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f, \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 4-\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0447\u0442\u0435\u043d\u0438\u0435, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435) \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/jmeter.apache.org\/\" rel=\"noopener noreferrer nofollow\">JMeter<\/a>. 50 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e 200 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u0430\u0436\u0434\u044b\u0439, \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438:<\/p>\n<figure class=\"\">\n<div><figcaption>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 JMeter<\/figcaption><\/div>\n<\/figure>\n<p><a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=jmeter%2Ffabio.jmx&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">\u0424\u0430\u0439\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 JMeter<\/a> \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432 (\u043f\u043e\u0440\u0442 8085)<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b JMeter \u0434\u043b\u044f CRUD \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM (\u043f\u043e\u0440\u0442 8086)<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432: ~58 \u043a\u0440\u0443\u0434\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u0440\u043e\u0442\u0438\u0432 16 \u043a\u0440\u0443\u0434\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/github.com\/google\/cadvisor?ysclid=m9rksakmje459875550\" rel=\"noopener noreferrer nofollow\">cAdvisor<\/a>, <a href=\"https:\/\/prometheus.io\/\" rel=\"noopener noreferrer nofollow\">Prometheus <\/a>\u0438 <a href=\"https:\/\/grafana.com\/\" rel=\"noopener noreferrer nofollow\">Grafana<\/a> \u0431\u044b\u043b \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0442\u0440\u0451\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0417\u0435\u043b\u0451\u043d\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d CRUD \u043d\u0430 \u0444\u0430\u0439\u0431\u0435\u0440\u0430\u0445, \u0436\u0451\u043b\u0442\u044b\u043c &#8212; PHP FPM<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0443\u043b\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u0411\u0414 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u0435\u043b\u0430\u044f \u0442\u0443 \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 3 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u043d\u0430 1 \u044f\u0434\u0440\u0435 \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, FPM \u043d\u0430\u0447\u043d\u0451\u0442 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0434\u0435\u0440, \u043e\u0434\u043d\u0430\u043a\u043e \u0438 \u0434\u043b\u044f \u0444\u0430\u0439\u0431\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0437\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439. \u0422\u0430\u043a \u0447\u0442\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043d\u0430 1 \u044f\u0434\u0440\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438, \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430.<\/p>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c CRUD, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>\u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u043d\u0430 \u0431\u0430\u0437\u0435 <a href=\"https:\/\/github.com\/nikic\/FastRoute\" rel=\"noopener noreferrer nofollow\">FastRoute<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/symfony\/dependency-injection\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0439\u0441\u043a\u0438\u0439 DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/laminas\/laminas-httphandlerrunner\" rel=\"noopener noreferrer nofollow\">laminas\/laminas-httphandlerrunner<\/a> \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438 PSR7 Response \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 PHP FPM.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/doctrine\/migrations\" rel=\"noopener noreferrer nofollow\">\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 Doctrine<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/packagist.org\/packages\/symfony\/validator\" rel=\"noopener noreferrer nofollow\">\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0439\u0441\u043a\u0438\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440<\/a> \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e CRUD-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432;<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0435 \u0431\u0443\u0434\u0443 \u043d\u0430 \u043d\u0438\u0445 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u043e\u0434 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0432 \u0447\u0430\u0441\u0442\u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0445\u043e\u0436 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0430\u0439\u043b <a href=\"https:\/\/gitflic.ru\/project\/cleancodemonkey\/fabio\/blob?file=src%2FDb%2FAsyncDb.php&amp;branch=aircraft\" rel=\"noopener noreferrer nofollow\">src\/Db\/AsyncDb.php<\/a>. \u0412\u043e\u0442 \u0432 \u0447\u0451\u043c \u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"php\">private function sendQuery(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket,     string $query,     array $params ): void {     if (!pg_send_query_params($connection, $query, $params)) {         throw new DbException('Error while sending the query.');     }     $start = time();     $readyTo = null;     while (true) {         if ($readyTo === FiberedHandler::SOCKET_READY_TO_READ) {             App::debugFiber($fiberedHandler, 'Consuming query result.');             if (!pg_consume_input($connection)) {                 throw new DbException('Error while consuming the query result.');             }         }         $flush = pg_flush($connection);         App::debugFiber($fiberedHandler, 'Flushing resulted with: %d', $flush);         if ($flush === false) {             throw new DbException('Error while sending the query.');         } elseif ($flush === true) {             App::debugFiber($fiberedHandler, 'Flushing has been finished successfully.');             break;         }         $fiberedHandler-&gt;addReadSocket($connectionSocket);         $fiberedHandler-&gt;addWriteSocket($connectionSocket);         $readyTo = $fiberedHandler-&gt;suspend();         if ($fiberedHandler-&gt;isTimeoutReached($start)) {             throw new DbException('Connection timed out while executing a database query.');         }     } }<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <a href=\"https:\/\/www.php.net\/manual\/en\/book.pgsql.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PgSQL<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435, \u0430 \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432, \u043d\u0435 \u0436\u0434\u0451\u043c, \u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0430\u0439\u0431\u0435\u0440\u043e\u0432. \u0422\u043e\u0447\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0411\u0414 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>pg_send_query_params()<\/code>  \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0444\u0430\u0439\u0431\u0435\u0440\u0430 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u0431\u0435\u0440) \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c <code>Fiber::suspend()<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0445\u043e\u0436\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>pg_consume_input()<\/code>, <code>pg_connection_busy()<\/code> \u0438 <code>pg_get_result()<\/code>. \u042d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/libpq-async.html#LIBPQ-PQCONSUMEINPUT\" rel=\"noopener noreferrer nofollow\">PostgreSQL libpq<\/a>. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PosgreSQL \u0434\u043b\u044f PHP \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430, \u043d\u043e, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u044d\u0442\u043e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 libpq, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043d\u0430\u0431\u0436\u0435\u043d\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"php\">private function receiveQueryResultAndFetchAllRows(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket ): array {     $result = $this-&gt;receiveQueryResult($fiberedHandler, $connection, $connectionSocket);     $rows = pg_fetch_all($result);     if ($rows === false) {         throw new DbException('Error while extracting the data from the query result.');     }     if (!pg_free_result($result)) {         throw new DbException('Error while freeing the query result.');     }      return $rows; }  private function receiveQueryResult(     FiberedHandler $fiberedHandler,     Connection $connection,     Sock $connectionSocket ): Result {     $start = time();     while (true) {         App::debugFiber($fiberedHandler, 'Consuming query result.');         if (!pg_consume_input($connection)) {             throw new DbException('Error while consuming the query result.');         }         if (!pg_connection_busy($connection)) {             App::debugFiber($fiberedHandler, 'The query result is ready. Going to read it immediately.');             break;         }         App::debugFiber($fiberedHandler, 'The connection is busy. Waiting for the data to read.');         $fiberedHandler-&gt;addReadSocket($connectionSocket);         $fiberedHandler-&gt;suspend();         if ($fiberedHandler-&gt;isTimeoutReached($start)) {             throw new DbException('Connection timed out while executing a database query.');         }     }     $result = pg_get_result($connection);     if ($result === false) {         throw new DbException('Error while getting the query result.');     }     $errorMessage = pg_result_error($result);     if (!empty($errorMessage)) {         $sqlState = pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);         if (is_numeric($sqlState)) {             $code = (int)$sqlState;       <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-457982","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=457982"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457982\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}