Answer the question
In order to leave comments, you need to log in
How to implement a very fast REST API in php along with a framework?
There is a ready-made REST Stateless API for a mobile application on the nginx stack, php-fpm 5.6 (w OPCache), yii2, redis, mysql, S3. The application is logically simple, of a general nature, like Instagram.
Task: get 5000-10000 RPS (number of requests per second), more is better.
Naturally, on a regular nginx + fpm, the figure is not impressive now, about 3000 RPS.
There are ideas to try HHVM, ReactPHP (ratchet) or even remake everything on Node.js (it will be more expensive to requalify and transfer all the logic).
Which stack to choose and which way to dig in order to get the coveted numbers and not spend a lot of time at the same time?
Answer the question
In order to leave comments, you need to log in
1. Find performance bottlenecks in the code using XHProf + fix them.
2. Review indexes in a DB. For example, FKs may be too high a price to pay for integrity.
3. All "heavy" processing that does not affect the output - put it in the queue: RabbitMQ / ZeroMQ / Gearman / ...
4. If there are no blocking dependencies - try on HHVM.
5. Yii model validation takes a lot of time. + Generation of models on selection (use asArray).
--
As for NodeJS, it won't save you much. The profit that you get is not a stateless system (general data can be stored in memory and you don’t need to pull the session / cache / database for them). You still need to be able to write under the node, at first you will have a callback on the callback and drive the callback.
--
In any case, sooner or later you will run into iron, therefore, think over the possibilities for horizontal scaling beforehand.
Specifically, in terms of speed, you can look in the direction of golang.
What jokes? Where does the 300 RPS figure come from?
They tied weights to RNR there, or what?
What is the proportion of RNR? Where are the tests showing that the bottleneck is a PHP framework and not, say, a base?
You would need node.js But in general, yes, 300 is something not enough
retraining is good! I think node.js is better.
I myself know it only superficially, but I have no tasks, no motivation =(
It will be, I will study it with pleasure ...
First you need to determine what can be squeezed out from the server in general on some simple native code that emulates the task, such as connecting to the database, opening a file on the FS, reading / writing something, counting, displaying and profile it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question