Search code examples
phplaravelamazon-web-servicescronddos

How to stop requests on PHP server while it is running cron job sheduled PHP script?


I have a situation when some DDOS attacks are putting my PHP server down. Occasionally.

I'm using AWS with auto scaling groups, so it is not a problem.

The problems start when this server is going down in the middle of the cron job scheduled PHP script.

So my idea was to block all of the routs on the PHP servers except for the /healthcheck...

How can I do that and is there a better solution?


Solution

  • have you considered creating secondary auto scaling group, specifically for the cron job? It would require setting up Scheduled Action like this:

    1. use this same launch config as your current auto scaling group
    2. setup second auto scaling group with "Scheduled actions" set to start the server (min / max / desired set to 1) at specific time
    3. update your cron with AWS CLI call to terminate the instance once completed by setting min / max / desired set to 0 on the newly created scaling group

    that way live system and cron jobs are separated and will not affect one another.