terfys
terfys

Reputation: 31

Using HHVM with FastCGI on a shared hosting server

I'm hoping that someone on here can shed some light on the below:

I'm busy setting up a shared hosting server using NGINX and HHVM with PHP-FPM failover. I'm planning on hosting between 100 and 200 Wordpress sites on the server.

HHVM is configured to use FastCGI. Is it possible to have a single HHVM instance running multiple websites, each as their respective Linux user? Or would my only option be to have everything running as the default www-data user?

I'm hoping to avoid the latter soup kitchen-esque environment due to the obvious security and cross-contamination risk it presents. I've seen mention made of running separate HHVM instances, one per website, but this sounds like a fairly resource intensive option.

If it's not possible to have one HHVM instance with FastCGI and have each website's PHP processes run as the respective Linux user, I'll probably opt to drop HHVM in favor of PHP-FPM which will allow me to achieve the latter.

Any tips or advise would be greatly appreciated!!

Thanks

Upvotes: 2

Views: 757

Answers (1)

Josh Watzman
Josh Watzman

Reputation: 7260

While it's possible to have a single HHVM instance serve many shared sites (it's a pretty straightforward nginx configuration), it's still a single HHVM process serving all of them -- i.e., running all as the same user. If you need to have full separation between each site, you'll have to run a separate HHVM instance for each. Making this shared hosting setup work more smoothly is something the team hopes to work on at some point.

This is a performance tradeoff. HHVM by default runs as a single process, where each request is a thread inside that process. This allows HHVM to serve requests more efficiently: it's not forking off a new process for each request, and, if you're serving a bunch of requests to the same site, the requests can share data, such as the compiled bytecode and assembly (the "translation cache").

The PHP-FPM model is actually similar to the latter idea you suggest to solve your problem: PHP-FPM always forks off a new process for every request. It has no option for a threaded model, which HHVM does. Of course, processes probably are what you want in a shared hosting environment anyways.

However, PHP-FPM has a somewhat lower startup cost and memory overhead per process than HHVM does. That tradeoff is up to you and your customers. Making HHVM work better in a shared hosting setup like this is, as I said above, something the team hopes to make work more smoothly at some point.

Upvotes: 2

Related Questions