Is it possible to throttle the upload speed of backups?

monkey64

Well-Known Member
Nov 6, 2011
123
5
68
cPanel Access Level
Root Administrator
My daily WHM account backups run at 2am each morning and save to Amazon S3. I run an ecommerce site and I have a couple of order issues around this time where the server has not been able to complete the required processes. I suspect that the backups are sucking the available bandwidth away from the server or in some way using up it's resources because the issues only happen at this time.

There are no errors shown in the Apache log or the PHP-FPM logs and the domlogs show that the correct pages were accessed (200 header code), which means that the server was indeed alive.

Does anyone know if it possible to throttle the backup bandwidth at all?

Thanks
 

rbairwell

Well-Known Member
May 28, 2022
98
42
18
Mansfield, Nottingham, UK
cPanel Access Level
Root Administrator
I'd first suggest actually installing Munin via WHM->Cpanel->Manage Plugins, wait a day or two, and then look at WHM->Munin->Network to see what network usage is happening at the time. (If your data center doesn't provide this information and you've got no 3rd party monitoring in place).

You might want to look at changing the backup times (under Server Configuration->Configure cPanel Cron Jobs) if 2am is a busy time for you. I'm not aware of a in-built cPanel bandwidth/throughput limiting thing for backups.

You could try, under WHM->Tweak settings, to reduce the compression settings (which will then reduce the CPU usage, but will increase the filesize of the backups) and also under Tweak Settings->Settings, you could change the "I/O priority at which nightly backups are run" and under Tweak Settings->Stats and Logs->"Extra CPUs for server load" you could reduce that setting.

You could look at using IPTables to rate limit outbound packets to S3 (see ServerFault or Stackexchange or Liunuxquestions for inspiration on how to do this). However, since S3 operates on ports 80/443, you'll need to be careful to restrict this to S3's IP range as otherwise things such as calls to Paypal/Stripe etc for payment confirmations will be impacted - Amazon do make their IP ranges available (see their knowledge article), but it will involve keeping the list up to date.

Jetbackup does offer a CPU Limit, IO Read limit and IO Write Limit restrictions (under Settings->Resource), but whilst that does support S3, Backback and many others, I can't see a way of limiting the used bandwidth within it.

The other alternative I can think of is to just save the backups locally and then use rsync with the --bwlimit setting to push up to S3 (which you could then use WHM's Backup Configuration->Custom destination to setup) OR you could try modifying the appropriate file /var/cpanel/backups/ (which is read by /usr/local/cpanel/Cpanel/Transport/Files/AmazonS3.pm ) to add the max_bandwidth parameter and see if it works (I haven't tried it myself).

[ Edit: I've just noticed that you *might* be able to use aws configure set default.s3.max_bandwidth 5MB/s as root from the command line to limit it - according to this blog post ]
 
  • Like
Reactions: monkey64 and cPRex