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.

stix
  • 812
  • 2
  • 7
  • 22
  • 2
    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) – Mark Baker Sep 15 '13 at 18:50
  • 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 architecture – Mark Baker Sep 15 '13 at 18:52
  • 1
    @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 :) – chillers Jan 06 '14 at 01:49

2 Answers2

7

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

Alex
  • 1,605
  • 11
  • 14
  • 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? – stix Sep 15 '13 at 19:18
  • 2
    By default, APC checks if file has been updated on every request. Please read a short description http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat – Alex Sep 15 '13 at 19:29
1

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

Barif
  • 1,552
  • 3
  • 17
  • 28