-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Enable opcache and use it with the file cache #14
Conversation
Opcache usually works in memory, compiling PHP code to opcode and caching it in memory between HTTP requests. Since on lambdas the PHP process is terminated between requests, the classic behavior of opcache doesn't work (the cache is cleared every time). To make opcache work we enable its "file cache" mode where opcache writes the opcode into a file (with the `opcache.file_cache` option). When the PHP process starts, it reads the opcodes from the file cache.
OK I think I understand why I don't see any difference in performances, what I did is not enough for opcache to get loaded. I need to bundle the |
On the API platform demo, when getting a list of books (uses the database):
This is very good news, it means opcache in CLI mode is very useful too. |
Impressive! Thanks 🙌🏼 |
Enable opcache and use it with the file cache
to be honest, I dont get why the file-based opcache works. will the opcache file, which gets created on the first visit be persisted with the lambda and is available on subsequent requests? or do you somehow pre-generated the opcache while deployment or similar, and therefore the opcache-file-cache is part of the "software-package" as a whole? |
@staabm lambdas are warm after the first call (cold start) for approx. 45 minutes (at least that was the case when I last checked), this is to optimize infrastructure resources on AWS side, so opcache is OK for this time at least. |
👍 and I want to explore the possibility of generating the opcache file before deploying. That would probably require using a Docker image with the exact same PHP version and same file paths, but I was told on Twitter that this could be doable. |
Try to enable parallel build
Opcache usually works in memory, compiling PHP code to opcode and caching it in memory between HTTP requests. Since on lambdas the PHP process is terminated between requests, the classic behavior of opcache doesn't work (the cache is cleared every time).
To make opcache work we enable its "file cache" mode where opcache writes the opcode into a file (with the
opcache.file_cache
option). When the PHP process starts, it reads the opcodes from the file cache.