Why can memcached cache support high concurrent reading and writing?
1. Multiplexed I/O model
In traditional I/O, the system may wait until a user's I/O connection is not ready until the connection is ready. When other users connect to the server, they do not get a response due to system congestion.
The multiplexed I/O model is a message notification mode. After the user is ready for I/O connection, the system will notify us that the connection is ready for I/O, so that it will not block a user's connection, which is why memcached supports
High concurrent reading and writing
2. Multi-threading model
The multi-threading model is divided into:
Main thread: mainly accepts client connections, pushes the connection to the sub-thread CQ queue, and notifies the sub-thread Thread, there is a client connection that needs to be processed
Child thread: After receiving the notification, the child thread takes out the connection from the CQ queue and registers with libevent to monitor the read and write operations of the client
Please upload the source code when you have time!
The above introduces the execution process of memcached caching, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.