Scalability with PHP on shared plans

software development

#1

Hey all,

I’m about to enter a partnership which could send as many as 10s of millions of page views to my site on a monthly basis. I’m just wondering if anyone else out there has any experience with a LAMP (Linux, Apache, Mysql, PHP/Perl) based site under these kinds of loads. I’m probably going to have to upgrade to a dedicated server to handle it, does anyone know how smooth that kind of upgrade is at DH?

–Brad Barkhouse
Be a Contender!
http://www.beacontender.com
brad.barkhouse@beacontender.com


#2

Biased, of course, but I’ve found that upgrades from shared to dedicated go pretty smoothly for the most part. We have the process down pretty well by now; your account stays the same, the domains, databases, mail etc. all gets moved over to the new machine.

The main thing is just making sure that you get a buff enough dedicated machine to handle the load you’re expecting; we can do some further tweaking to Apache and MySQL if your site gets really busy. Since our shared hosting database machines are pretty buff, we’ve had some people who have run into problems when their database moved from shared hosting to a newmoon dedicated machine (especially if they didn’t get extra RAM).

I would suggest running some tests (on the shared server) to evaluate the number of database connections and amount of bandwidth you use (when the site isn’t busy), and then contact support / sales… have them put you through to Jason or Micah (other admins here), who should be able to help you decide what type of hardware is necessary.

We do have some pretty busy sites on shared hosting, but dynamic sites definitely take up a lot more resources than a static site, and often this type of site will become a problem. Note, of course, that sometimes bad coding is also the cause - I’d spend some time on that… no sense spending lots of money for a dedicated machine that’s not necessary.


#3

Yes, I agree that testing is the key. I’m running on some pretty tight deadlines, but I’m also waiting to hear back from a partner to get a more accurate number of potential visitors. Maintaining all other ratios of hits and bandwidth per visitor, we should be able to calculate the projected totals expected.

Our PHP scripts and DB tables are already quite optimized, with little to no duplicated code, but we’re also hoping on using Zend’s accelerator to give a bit of a boost to the PHP engine.

Thanks for your input!

–Brad Barkhouse
Be a Contender!
http://www.beacontender.com
brad.barkhouse@beacontender.com


#4

[quote]Our PHP scripts and DB tables are already quite optimized, with
little to no duplicated code, but we’re also hoping on using Zend’s
accelerator to give a bit of a boost to the PHP engine.

[/quote]

That will probably help, though it’s not an option unless you have a dedicated server (and even then, we’d probably have to install it for you as it’s not installed by default).

Also, make sure you have cached as much content as possible. Re-generating something every 30 minutes and writing it to a file is usually better than re-generating it upon request if A) most site visitors are seeing the same thing, B) the content doesn’t need to be absolutely fresh, and C) you’re getting tons of traffic.

Finally, MySQL v4.0 introduces query caching, which can greatly speed up certain kinds of queries if the exact same query is repeated over and over. The downside is that we don’t currently support MySQL 4.0, but it’s definitely on the way.

As always, be sure that you are using indexes properly with your database tables. In my own projects I’ve seen speed-ups in the order of 10x as fast after adding certain indexes.

Also consider using persistent DB connections.

I don’t think you’ll find any problems with PHP itself scaling, though it’s largely dependent on how your code is written and the hardware you throw under it. There are some rather high traffic dynamic sites running PHP out there. Admittedly, few of them are probably running on shared hosting, and have buff hardware as a foundation.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#5

Jeff is it possible for the zend accelerator to be enabled via .htaccess or with a run-time config variable for the CGI version?

My main reason for wanting the accelorator is the ability to run encoded content. The Zend Encoder gives developers the ability to encode their projects and thus make software licensing actually possible.


#6

[quote]Jeff is it possible for the zend accelerator to be enabled via
.htaccess or with a run-time config variable for the CGI version?

[/quote]

My impression is that it needs to be compiled directly into the web server, and the nature of accelerator is such that it requires persistent (ie. it can’t be used with CGI).

I really don’t know a whole lot about it, though, so I’d check with the Zend people first.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#7

so if it doesn’t need to be compiled into Apache and it works with my own compiled PHP running as a CGI, then it should be ok for me to run it on my dreamhost account?

It seems like it might be worth a try… I’ve read a bit on the zend site and it seems like it’s just a matter of putting the optimizer libraries somewhere and then changing a few settings in your php.ini file to enable the optimizer and tell it where to find the optimizer files.

they talk about starting and stopping apache but I"m wondering if that’s only necessary when PHP is running as an apache module and not as a cgi.

–Brian


We are the music-makers, and we are the dreamers of dreams.


#8

[quote]so if it doesn’t need to be compiled into Apache and it works with
my own compiled PHP running as a CGI, then it should be ok for
me to run it on my dreamhost account?

[/quote]

Certainly. As with any software we reserve the right to ask you to stop using it if it causes problems, but that seems rather unlikely if it’s running as a non-persistent CGI process. If you can get it to work, feel free to do so.

If you can, please let us know how it works. If it works well enough, I might suggest this route for others looking for Zend Optimizer support.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#9

I’m pretty sure it’s dumb to put the Optimizer in there (unless you just want it for the encoded-script support). It won’t make anything faster (it’ll just increase the mem. usage of the script) because it “optimizes” PHP by just caching the bytecode-compiled script in memory.

This works when you’re running PHP as an Apache module because the interpreter (and the mem-cached bytecode) lives as long as the Apache child process does. So the second, third, etc times that child process gets asked to run the script it doesn’t need to compile it again.

However, in CGI mode the interpreter quits after every execution. So it compiles your script into bytecode, caches it in memory, executes it, then promptly dies, taking the bytecode with it.

This is my understanding of the Optimizer, anyway. I’ve helped a couple customers install it and in my experience it’s only slightly more than worthless.

nate.


#10

[quote]I’m pretty sure it’s dumb to put the Optimizer in there (unless you
just want it for the encoded-script support). It won’t make
anything faster (it’ll just increase the mem. usage of the script)
because it “optimizes” PHP by just caching the bytecode-compiled
script in memory.

[/quote]

Right - in my experience, though, 90% of the people who ask for it do so because XYZ script they want to use requires it. I’m not sure that the memory persistence benefit is even being considered in most cases.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#11

Well… it seems to be working in CGI mode. I added it to the php.ini file and if you do a phpinfo() the optimizer shows up… but I agree with nate’s previous post… in cgi mode it doesn’t seem to make that much of a difference except it probably adds to overhead…

–Brian


We are the music-makers, and we are the dreamers of dreams.


#12

Hello, I have php program that requires Zend optimizer to work. However, I am not sure if I can install it on the server. I do not have a dedicated server.

Thanks
Tony
urbanevolution.com