5

I am starting a small web hosting company to teach me about system administration and one of the problems I am having is how would I limit the bandwidth and disk space of each virtual host (Debain/nginx)? Or am I going about it the wrong way and should not use virtual hosts?

2
  • I absolutally agree that doing it is the best way to learn, and I applaud your initative. However a web hosting company generally has someone who already knows what they're doing, because you don't want to lose everyone's data by accident because you're still learning - even if they haven't paid you any money for it. Jul 21, 2010 at 4:31
  • Sorry, I thought I posted it on server fault, and it is not really serious, it will be a free web host with small limits. Jul 21, 2010 at 4:55

4 Answers 4

2

I have used mod_bandwidth to restrict bandwidth. It can be used per directory, per file, etc... so, you just have to configure it per VirtualHost.

For the Disk Space, just use the quota. Create a unix account per customer, and assign them the quota. That should be quite well documented in the web.

1
  • But throttling bandwidth pushes load back onto the server - so you could end up with a DOS
    – symcbean
    Nov 22, 2011 at 10:33
1

Some quick Googling shows me that you could use a Squid proxy to set queues for data called 'data pools'. You can apparently also use IPROUTE2 and TC (can't post link, I'm not awesome enough)

From http://www.faqs.org/docs/Linux-HOWTO/Bandwidth-Limiting-HOWTO.html#AEN65

Apart from normal caching, Squid has a special feature called delay pools. Thanks to delay pools, it is possible to limit internet traffic in a reasonable way, depending on so-called 'magic words', existing in any given URL. For example, a magic word could be '.mp3', '.exe' or '.avi', etc. Any distinct part of a URL (such as .avi) can be defined as a magic word.

Also see an article on serverwatch.com titled Reining-in-Bandwidth-With-Squid-Proxying

Squid is probably the simplest way, and you can do a lot of other cool things with it, too.

0

Its not simple. I suspect that it won't be possible simply using vhosts to enforce limits unless you put a scripted proxy in front of the webserver (and that only addresses the bandwidth problem, unless you restrict file uploads to a scripted web interface).

But surely it makes more sense from a business point of view to sell a package which includes X bandwidth and Y disk usage then bill the customer for excesses (which you can measure easily from the disk footprint and the access logs).

C.

1
  • That doesn't work if the customer degrades service to other customers. Even if you bill for overages, you still usually need a limit. (Plus, your $50/year customer may balk at the $1,000 bill if they host a video that goes viral. So you usually still need a limit.) Nov 21, 2011 at 21:20
0

To limit total bandwidth usage refer to the KikoV answer, I'm discussing about limiting disk space.

In fact there's no straight way to limit disk space, but you have two options:

  1. You can schedule a script which calculates used disk space for example every day and bans/alerts exceeded clients.
  2. You can create a system user for each of your clients and use the file system quota manager. Read this article for more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .