For two years I wrote microservices on Go using Swagger-based code generators. It turned out quite compact and very fast solutions.I am currently using PHP, so I decided to find means to solve the same problems in the language ecosystem. I know and love Laravel and Symfony, but I didn’t want to drag them into projects - there are too many batteries for which you have to pay a steep curve for entering the project and performance.As a result, Comet appeared - a modern PHP-based framework for developing fast APIs using the experience of SlimPHP and Workerman teams. Tens of thousands of RPS on a regular virtual machine and less than a millisecond latency!In order not to be unfounded, I will give the results of testing of Comet and other popular frameworks. For a more honest comparison, all heavy modules like ORM were removed from the assembly of all test participants.The first case is an imitation of a high load in the form of thousands of competitive wrk requests for a method that returns “Hello, World!” Welcome line in plain text:
To estimate the minimum delay, we used the option in which a single client sequentially sent one request to the same endpoint:
As can be seen from the results, the features of the Comet architecture allow you to process a ten times larger stream of requests with minimal delays than traditional frameworks.Let's take a look at the code to get an idea of what you will encounter in real development on Comet:use Comet\Comet;
require_once __DIR__ . '/vendor/autoload.php';
$app = new Comet();
$app->get('/hello', function ($request, $response) {
$response
->getBody()
->write("Hello, Comet!");
return $response;
});
$app->run();
Everything is pretty transparent: using a router and closures provides a compact code, more similar to what NodeJS / Express developers are used to.I have posted all the code on GitHub and plan to expand the capabilities of the framework:https://github.com/gotzmann/cometI will be glad to comments, commits and, of course - the use of Comet in real projects :)