I'm using OpCache since it came with PHP 5.5.x and I'm really pleased with it, but I would like to tune its memory settings and that's where my understanding comes short...
When a given user requests a given page, the server answers this requests, calls the PHP interpreter, the interpreter stores the opcodes in the cache, serves the content, and that's about it. The next time a request comes in, the cache kicks in if the requested opcodes are the same, but my questions is...
The cache is working on a per-user basis (and the cached opcodes apply only for this specific user's requests) or do they apply to any request making use of those cached opcodes?
What I would like to do is tune OpCache to use a certain ammount of memory but I don't know if the memory pool works on a per-user basis or it's acting like a shared pool of resources.
Can you give me a hint?
You are already right about how the opcode is stored in cache and read from the shared memory. It is however not on a user basis, but rather on a script level. Each php file that has been parsed and compiled to opcode will be saved to the shared memory and executed from there. The parsing and compiling steps, which are otherwise slow, will be shortcircuited for each script that has been cached.
To answer your questions, no the cache does not work on a per-user basis but rather on per-script. The cached opcode is still executed by the scripting engine (Zend mostly) per request.
And yes it does read from the shared memory.
Reference D. Shafik: Everything You Need to Know About OpCode Caches
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With