nominatim-docker icon indicating copy to clipboard operation
nominatim-docker copied to clipboard

Use Nginx + php-fpm for better performance

Open AnthraX1 opened this issue 3 years ago • 10 comments

Is your feature request related to a problem? Please describe. Apache with php-cgi suffers from performance issue when there is a lot of incoming connections.

Describe the solution you'd like Use Nginx web server with php-fpm instead of Apache2 + php-cgi

AnthraX1 avatar Aug 26 '22 03:08 AnthraX1

Do you have any tests / benchmark results to compare the performance between apache & nginx with Nominatim?

philipkozeny avatar Aug 27 '22 17:08 philipkozeny

I think nginx really is (or at least was) faster when you have thousands of concurrent connections. Is this what you're facing?

leonardehrenfried avatar Aug 27 '22 19:08 leonardehrenfried

I think nginx really is (or at least was) faster when you have thousands of concurrent connections. Is this what you're facing?

Absolutely, as I recall php-cgi on Apache2 is fork based, each connection would fork a new apache process. Though the database can't handle 1000x concurrent connections, it makes the pressure on the webserver and php much lower.

Nginx with PHP-FPM is also document in official installation guide, it's can be drop in place into the dockerfile.

AnthraX1 avatar Aug 28 '22 03:08 AnthraX1

My question was more along those lines: is a load of thousands requests/seconds a problem that you're facing or have you just read somewhere that nginx is faster than apache?

leonardehrenfried avatar Aug 28 '22 06:08 leonardehrenfried

Yes, for this reason I had to drop running it in docker and installed a vm version with nginx.

AnthraX1 avatar Aug 28 '22 15:08 AnthraX1

I would not be averse to switching to nginx but you'd have to solve the the log rotation which is a bit tricky.

Would you be willing to try nginx privately and send a PR when you've tested it with your high load environment?

@philipkozeny WDYT?

leonardehrenfried avatar Aug 29 '22 06:08 leonardehrenfried

I would not be averse to switching to nginx but you'd have to solve the the log rotation which is a bit tricky.

Would you be willing to try nginx privately and send a PR when you've tested it with your high load environment?

@philipkozeny WDYT?

sounds good to me.

philipkozeny avatar Aug 29 '22 06:08 philipkozeny

@AnthraX1 you can test with https://github.com/darkBuddha/nominatim-docker/tree/master/4.1-nginx

IMHO, Nginx should always be preferred over Apache.

darkBuddha avatar Oct 26 '22 10:10 darkBuddha

We have started the 'n7m' project, a Numeronym for Nominatim. It's not nearly as mature as 'nominatim-docker' but something we have been experimenting with.

This branch has a FPM docker image with n7m fronted with an official NGINX Docker image: https://github.com/smithmicro/n7m/tree/main

We have yet to do any performance tests comparing NGINX+FPM to Apache. Have at it!

dsperling avatar Apr 24 '23 03:04 dsperling

@dsperling That's a really interesting project. I hope you succeed and we can refer the people with more advanced use cases (which we have been reluctant to implement for fear of extra maintenance burden) to your project.

leonardehrenfried avatar Apr 24 '23 06:04 leonardehrenfried

@AnthraX1 - PHP-FPM support has now been merged to the main branch of n7m and is working extremely well. Comments welcome. https://github.com/smithmicro/n7m

dsperling avatar May 07 '23 21:05 dsperling