Question

I've made a chat system, which works with AJAX requests. Only after a few minutes to half an hour of chatting, my hosting provider starts blocking people, which is probably because it sees the AJAX requests as an attempted (D)DoS attack.

What are my best options?

Was it helpful?

Solution

Long polling?

I'm not suggesting that you should not use something like websockets or server sent events but, if for some reason you are unable to, then I guess you could try to reduce the number of AJAX requests by not closing them as soon as you currently do.

OTHER TIPS

Obviously you've built your ajax chat to load all messages on every ajax-call. Which is way too heavy on the server.

As noted by @Daniil, you'd better use websockets (eg pusher or slanger) to communicate realtime messages.

  1. Use websockets when you need to operate with data in realtime.
  2. If you still want to use AJAX, don't make too many requests to your script.

Use a less crappy host?

More seriously, make sure the number of AJAX requests sent is reasonable (one every 5 seconds should be fine). Make sure your host actually allows high activity such as chats, as most shared hosting probably won't.

You might want to get a VDS or even a full dedicated server depending on your needs.

  1. Move out to a different host.
  2. Optimize the code.

It can't be a firewall issue since you said it works for half an hour before being blocked. That's probably your hosting company's excuse to force you to move to a more expensive package.

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