0

I run a very dynamic game review site. All the images (screenshots, game thumbnails, user profile pics, etc.) are served via a PHP script on the server. It takes the id as a parameter and reads the data from the database, outputting it with a content header of image/[png/jpg]. In the very near future (less than a month), we are partnering up with another company. We anticipate traffic to the site to increase dramatically.

My estimate is that our traffic will increase to around 50k per day.

In the past, I have met with this error from our hosting server: you have reached the limit of scripts/processes run per second. I looked it up and found we have a limit of 20 simultaneous scripts (php, cgi, etc.) per second at any given time. On average, each page on our site has 50 images.

My first question is: is this a reasonable limit? Should I expect this sort of limits from other hosting solutions?

Second question:

Is this setup recommended for serving images? I can try to get a server which doesn't have this restriction, but I'm concerned if this setup scalable if we get even more traffic?

The alternatives I can think of are:

  • Store the image as a file on the server. The database will store the relative path to the image instead of the image ID. This way, at least the each image won't be a dynamic script that the server needs to run.
  • Run multiple image database servers that only serve images. How will the load balancing work then?

Any help would be appreciated.

l3utterfly
  • 111
  • 2

1 Answers1

2

I think most, important in scaling image serving is having caching in front. It can be Varnish or some CDN service. If cached well, backend is not so important for small size project. It can be a database quite well. While it has some overhead compared to static files, it may provide some basic scalability solutions like replication to multiple databases and manageability.

Main thing is to build in to a application early, that when any image changes, then changes its URL, too. And then you will be able to cache everything indefinitely :)

Kazimieras Aliulis
  • 2,324
  • 2
  • 26
  • 45