Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent connection #36

Open
5lava opened this issue Feb 21, 2016 · 2 comments
Open

Persistent connection #36

5lava opened this issue Feb 21, 2016 · 2 comments

Comments

@5lava
Copy link

5lava commented Feb 21, 2016

Most often use case in PHP is to detect a country/city of current request's IP address. In common fpm/fastcgi environment database file is re-opened and re-read on each and every request when MaxMind\Db\Reader instance is created. The idea is to keep database file opened as long as php fpm/fastcgi master process is alive. Simple tests show performance gain at least by an order of magnitude.
As as side note, database should be reloaded whenever its file size or timestamp has changed.

@oschwald
Copy link
Member

oschwald commented Mar 4, 2016

I am not sure this would be possible with the pure PHP reader. It might make sense for the extension, but we would need to figure out a reasonable way to provide a mostly compatible API.

@5lava
Copy link
Author

5lava commented Mar 4, 2016

Yes, I was talking about the extension of course. Speaking of API — that could be an optional boolean parameter to MaxMind\Db\Reader constructor. If set to true, an attempt would be made to reuse an existing file handle. Obviously, pure PHP reader would just ignore that parameter, and this behaviour is consistent to the extension's behaviour when no previously open file handles were found (i.e. "cold start").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants