Answer the question
In order to leave comments, you need to log in
What happens if I connect to a synchronous query on a database in a Workerman asynchronous socket server?
How exactly will this affect the system? It is very interesting to know opinions, I myself, at the moment, understand very poorly in these synchronous-asynchronous topics.
The answer is exactly what will happen if I synchronously connect to the Mysql database in an asynchronous socket server, which is built on Workerman + Socket IO.
The whole thing is in PHP.
Answer the question
In order to leave comments, you need to log in
I don’t know how exactly Workerman works, but in all implementations of asynchronous engines that I have ever heard of, a blocking call in asynchronous code leads either to degradation of the performance of the entire system or even to a hang.
If you have a synchronous request in your worker, then the worker hangs until the end of this request. The actual result depends on various parameters: how many workers there are, how requests are distributed among the workers, what is the load on the service. If this happens on a sufficiently large percentage of requests and the service is loaded enough, then at some point all the workers will start to hang. As the load increases, it will look like this: at first (as long as the number of workers is greater than the number of simultaneous requests) it may not appear at all, then there will be a large spread in the processing time of client requests, and then everything will die.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question