Question

I use Jelastic to host a PHP application. Editors can upload pictures through the application that are stored in the file system. These pictures are stored within the document root and are served on the frontend as e.g. http://example.com/uploads/123/picture.jpeg

For the NGinx application server, I have enabled vertical scaling but have a single node, i.e. no horizontal scaling.

Picture uploads are not reliable. When I update a picture #1 through my PHP admin interface, then update another one, picture #1 has changed back to the old picture.

My question: Are picture uploads sync'ed across multiple cloudlets on a single node? What will happen if I scale horizontally to multiple nodes?

Was it helpful?

Solution

My question: Are picture uploads sync'ed across multiple cloudlets on a single node?

I think there is a terminology problem here.

Cloudlet: A composite resource unit composed of RAM and CPU usage. 1 Cloudlet = 128MB RAM and approx. 200MHz CPU. A server (Jelastic refers to this as a 'node') typically uses multiple cloudlets; e.g. it may use several GB RAM and/or several GHz CPU at any given moment.

More details at http://kb.layershift.com/introducing-cloudlets

Each node is a self-contained (virtual) server, with its own filesystem. So if you have a single NGINX PHP application server, it doesn't matter if it uses 1 or 100 cloudlets (remember, this is only a measurement of RAM and CPU consumption!), it has 1 filesystem and all of the files that you successfully write there will be available for any subsequent requests.

What will happen if I scale horizontally to multiple nodes?

Right, you have to be careful here. If your application is writing to the local filesystem, you have a problem when dealing with multiple horizontally scaled servers. This is a very typical scaling problem that every application must deal with.

If we're simply talking about static resources (e.g. images), one of the best and simplest ways to handle this issue is to upload all of those to a single server. For example if you have 4 NGINX PHP servers - let's say they load balance your-application.com - you might make one of those servers (or perhaps a completely separate environment) images.your-application.com

So you perform the uploads to images.your-application.com, and reference that directly in your HTML when you wish to display those uploaded images.

Remember, images.your-application.com is only responsible for serving the actual images; so it's really lightweight and should handle a decent volume simply with vertical scaling - which is completely automatic on Jelastic.

When you need to scale images.your-application.com, the easy way is to take a CDN service (CloudFlare, Incapsula etc.). This will leave images.your-application.com only handling the uploads and the small amount of download traffic which is not already cached at the CDN.

OTHER TIPS

Having the same issue, please read this jelastic tutorial.

In summary, jelastic have a script which help you with sincronization, you just have to execute the script and indicate the folders you want to sync in all nodes.

Then, everytime you upload a file to those folders, in cuestion of seconds or minutes the files will be available for all nodes; the time is depending of the file size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top