Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have made a chat application.
The messages are being shown in the message box that is continuously fetching the updated messages from the databases every 10 ms through ajax.
Every new message sent is seen in the message box instantaneously. So it gives an illusion of real chat without delay.
My problem is once the application goes live, I am getting told that a mysql account
cannot exceed query request of 1500 queries per hour from database.

What I have tried:

I googled and found some tweaking needs to be done with Grant tables which allow to raise the bar to unlimited supposedly. After doing some research I ended up blowing my databases altogether of not only this project, but for others as well on my local xampp server. Sad.

I just need to know that is grant table the only way to workaround the problem or is there another way to it.
Posted
Updated 5-Apr-19 20:05pm
Comments
Thomas Daniels 6-Apr-19 6:16am    
Instead of fetching the messages every 10ms, you might consider using WebSockets to maintain a connection between the clients and your server, that works way better for this purpose.

1 solution

Basically, you need to change the whole way you are doing this: if your hosting service restricts you to 1500 requests an hour, then that is probably 1500 requests across all of your users. so if you have 1500 users trying to chat, that's one request per hour each.

You will need to either change your hosting service (and probably pay for it, I've only seen limits like that with free accounts) or change your whole design to a "push" model rather than "pull" - probably both, since a 1500 request per hour works out at 60 * 60 / 1500 = 2.4 seconds between requests on average. Even paid for accounts are going to get pretty slow and cumbersome as user numbers rise with your current method - when I ping Google.com, the round trip time exceeds 10 ms so your whole system is going to fail because requests will only just reach the destination before you start making another, let alone access the DB and get back to your client!

Try this: open a new CMD window and type "PING nameOfYourDomain" then press enter.
ping google.com
ping codeproject.com
If the values under "time=" aren't less than 10ms (and they won't be) your system will tie itself in knots very, very quickly ...
 
Share this answer
 
Comments
goldensquare 6-Apr-19 2:26am    
I pinged my domain and the average time is 169ms. This is way above 10ms. My hosting is indeed free, probably that is causing the restriction.
I am interested in reading about these "push" and "pull" design models. Perhaps you could refer me to some good resource online.
OriginalGriff 6-Apr-19 2:42am    
https://www.google.com/search?q=online+chat+app+Php&rlz=1C1CHBF_en-GBGB754GB754&oq=online+chat+app+Php&aqs=chrome..69i57.8064j0j7&sourceid=chrome&ie=UTF-8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900