PHP Magazine Network and Hosting of AWS AJAX Demos
Maybe you noticed since few days there was no posts and some posts that have been added on sunday are no longer available. The whole story was about our hosting account, which is currently a shared hosting but advanced as its name indicates. But the problem that the hosting provider is very anxious about resources consuming, almost every month I got an email from their abuse service, fix your scripts or go out and they have no problems to say it.
I have in my plans to move very soon to a dedicated server, but currently there is no need to spend $200/month on a server that I won't really use. Today current use of the server looks very normal for me CPU% 1.55, Memory% 4.02, nothing special for a static website running only few AJAX demo with PHP. Top Process today %CPU 99.0 proxy.php, which is the script I used for the AJAX and AWS demos. I have disactivated the script until I fix this issue, but see why the abuse service was worried :
The proxy.php script is using 99% of cpu and if that is an anonymous proxy script it will need to be removed as we dont allow proxies on our server. Top processes shouldn't exceed 25%. We also would like to see daily memory usage below 3%.
It's not the first resources issue we had with this hosting provider and we used to move from a publishing plateform to another many times before finding the suitable configuration for both. But what makes me sick is that monday I discovered that there was dns problems with the server, after contacting the support service I discovered also that they have moved my website without informing me, but also used an old backup. There was about 8 articles lost and I don't know what else since I didn't have time to make a backup myself. Moral of the story, we can't keep the AJAX demos for long time, and if you plan to use AJAX don't do it on shared hosting.
Concerning the AJAX and AWS demos, I just wanted to show the features that we can create using the Amazon WebServices. But the basic of the scripts are a little resources consuming since everytime the client make a request, the server call the remote Amazon method to fetch data then process it locally to send it back to the client.

The problem is that this process is created for every AJAX request, for example in the first demo using search with keywords for every keyup event the server will make a remote request to Amazon fetch the data process it and send it back. As result we will have a very flexible interface but in the other side a very busy server, you can imagine this process running by many users in the same time.
The solutions are many, first we can work on the interface itself for example use a search submit button inspite of the keyup event. Catching the even make a very nice effect, but we are not sure that the user have finished writing his keyword, so we are already creating more requests than needed. The same for the slider, if you click on the slider and keep moving right and left, an AJAX request is send for every step, which mean if you move from 0 to 20 the script can make 10 requests at 2,5,8,10,12 ... while the price we are looking for is 20.
This is for the client side, in the server side it's possible to use caching for the results so for one keyword request you make only one remote request to AWS every 24h for example. If the user requested the same data again, the server will retrieve it from cache, which will be faster and less resources consuming.
These are some thoughts to optimize the latest demo I have created for using Amazon Web Service with AJAX, and I'm sure that we'll have more technical articles in the future discussing different aspect of AJAX solutions.


Subscribe to AJAX Magazine's feed