As I understand, the popular consensus today is that nginx+php-fpm performs faster than apache even with the mpm_event process management enabled?
But when it comes to real world usage, many production instances I observe these days still deploy apache a lot. Even cpanel based web hosting (shared or dedicated instances) are more often apache based than nginx.
Is it due to some old habits and dependence on apache specific features like .htaccess support? Or is it the case that apache has actually caught up in the race with ngnix and the performance difference is quite negligible these days?
When people ask these questions, do they think people are actively choosing to use the old technology? That's a huge misunderstanding. It's not an apache vs nginx decision. It's do nothing vs spend precious time on a side quest to upgrade. Opportunity cost is your answer.
And re: performance, keep in mind that very few applications are limited by the speed of their HTTP server. You first look at your application servers, networks, disks, databases. If your app is truly HTTP-bound, well you're probably not still using Apache! IOW the people who NEED to upgrade from apache for performance reason already have. For the rest, there is no incentive.
Technology should solve business problems. If the move from Apache to nginx isn’t going to solve an actual problem, it becomes technology for technology’s sake.
In some cases, squeezing out a little extra performance does matter, but for most sites, I don’t think it’s that big of a deal.
What killed Apache for me were the complexity of various rules and how challenging it is to define a proxy for a WebSocket connection. NGINX is better but still not great.
For me anything can be connected to anything else easily and quickly. A network connection, a socket, is a pipe containing a full duplex stream. So, just pipe one socket to another, and vice versa, and you have a very low level proxy. The rules to define such for a users customization is just as simple as what should go where.
Knowing all of that, and that HTTP is not full duplex, I serve HTTP and WebSockets from the same port with a preference for WebSockets by default. I can also pipe other streams to sockets for lower CPU overhead. I have not tested if my server is faster and less CPU overhead than NGINX yet, but it does concurrency very well.
Using nginx might enhance a bit performance, but compared to other modules of the overall environment such performance gains are neglectable and unnoticeable for a normal user.
In our latest product I wanted to switch to nginx but I was surprised that for windows it is only in BETA version, and since our application MUST be deployable to both Windows and Linux environments we preferred a consistent software stack hence we stick on Apache.
The plan is to reconsider nginx once it officially supports windows, since no serious customer would accept a beta version for a production environment.
FPM workers get stuck, default settings need to be changed, can’t handle long-running connections well, ends up using a lot of ram. More log places to check when things go wrong.
You end up with more issues.
You may ask why Apache then? Well, because when a user modify some settings via dashboard, they change in .htaccess which does not expect a web server restart or super user permissions like you need with NGINX, for example.
Now you know why WordPress websites are getting hacked easier than other CMS-es...because they can apply changes in .htaccess on the fly, whereas with other web servers, you need root permissions, thus the extra layer of security.