Php – How to flush PHP-FPM OpCache on an autoscaling PHP cluster

amazon-web-servicescacheopcachePHPphp-fpm

On our current monolithic LAMP servers we deploy via Capistrano and reload PHP-FPM at the end of a deployment, in order to flush the Opcode Cache.

Now, we're building a new webhosting cluster on AWS for dozens of PHP 7.0 and PHP 5.5 applications. The application-servers with PHP-FPM will autoscale horizontally. PHP code will be stored on an NFS server and static assets on Amazon S3.

How do I flush all the OpCaches after a deploy when I don't have a fixed list of hosts?

Best Answer

Storing code on NFS is not funny though. Anyway, you can use mcollective to send a message to all connected servers.