How APC opcode cache works
Asked Answered
D

2

6

Can I use apc opcode cache if I can (not must) have unique content for each visitor on same page? I'm not sure I understand how opcode working. If only save php result to cache and serving it like "html", then it's useless for me. I definitely need to run sql queries on each pageview. Or it's any better way how to optimize php? App have very high-load - about 1000 pageviews per second. It run on nginx + php-fpm.

Dorren answered 15/9, 2013 at 18:49 Comment(3)
APC opcode cache stores the bytecode (opcodes) generated when your PHP script is "compiled"... so it can be executed time and time again without needing recompiling.... it does not generate the result of execution (unless you specifically tell it to)Speleology
But it's still always a good idea to optimise the PHP Itself.... 1000 pageviews per second is pretty high usage especially if you're only running on a single server, so you should probably look at a better performant architectureSpeleology
@MarkBaker I use PHP with APC on a single server handling 5k -10k rps with no issues and server load almost .25 That's with mysql reads/writes and a few .ini and .dat files with no issues. Only a 4 core server with 8gb ram. It's all about the tuning :)Framing
R
7

Yes, you can. APC caches the program, not its' result. So, the code will be executed each time, just in "optimised" way.

Rensselaerite answered 15/9, 2013 at 18:51 Comment(2)
Thanks for easy and fast explanation :) And if I upload new version of php and old is in cache - apc load old code for TTL time or check file for new version?Dorren
By default, APC checks if file has been updated on every request. Please read a short description php.net/manual/en/apc.configuration.php#ini.apc.statRensselaerite
L
1

How to determine which resource object loaded from, cached opcodes or compiled newly?

Lehr answered 29/4, 2014 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.