Home  >  Q&A  >  body text

Apache prefork and worker issues

Apache prefork handles requests with multiple processes. The worker mode is a process that uses multiple threads to handle requests. It is equivalent to multiple processes plus multiple threads. It can process more concurrent requests and consume less memory and CPU, but there are threads. Security issues. There are a lot of comparisons on the Internet about the differences between these two modes, all of which talk about the multi-process and multi-threading I mentioned.
Question 1: Since worker mode can improve high concurrency and save memory and CPU, why does Apache still use prefork mode by default?
Question 2: If Apache uses worker mode, and then uses Linux's epoll mode, can it support more than 10,000 concurrencies?

高洛峰高洛峰2713 days ago404

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 17:05:39

    Apache can of course use worker mode to process PHP. As you said, the ability to handle concurrent requests will increase and memory and CPU consumption will be less. However, the only drawback is that prefork is multi-process and multi-threaded, and some PHP extensions have thread safety issues, so if there is no thread-safe PHP extension, you can use it, but if it exists, it is best not to use it, otherwise it will cause data inconsistency. In addition, if apache uses epoll, it will It’s possible, but it’s probably a bit difficult to run over 10,000 concurrent users

    reply
    0
  • Cancelreply