Score:0

File hosting on multiple servers?

US flag
user1033035

I have a PHP website for file hosting (like Dropbox) on a Debian server with Apache, but I'm running out of disk space. Is there a way to add another server in the network and somehow make Apache use the two servers as one? I've heard it can be done with Load Balancer, but I'm not familiar with it. I've Google'd it but it only mentions performance, so I'm not sure if I'm on the right track?

djdomi avatar
za flag
you can use hundred servers if you use a reverse proxy like nginx infront of.
Zac67 avatar
ru flag
*I'm running out of disk space* - it's likely much easier and cheaper to expand the server's storage.
Score:1
kn flag

Short answer: Not done that way.

A website may be made up of multiple servers. But, that is only for load balancing for the CPU, RAM or bandwidth for heavily used sites. Generally speaking, the contents of those servers are duplicated. (Not always the case, but for your case, yeah.)

In your case, you say that you are running out of space, so you need more space, not multiple servers.

The easiest to manage option (i.e. least technical knowledge required) is to add a second hard disk to your system. The disk can be added to an internal bay, or even attached via USB. Then you move the contents of your Apache directory to that disk, update the home directory setting, and Bob's your uncle.

There are lots of other options. Such as moving to a hosting provider such as Digital Ocean or GoDaddy or Amazon. But, for now, just add a second disk.

Paul avatar
cn flag
At least one other reason to use multiple servers is redundancy.
Score:0
ru flag

I'm running out of disk space.

Depending on the server model, it might be easier and less expensive to expand its storage or replace the server.

Is there a way to add another server in the network and somehow make Apache use the two servers as one?

Not exactly "as one" (that easily) but side by side. Use a load balancer as a standalone appliance, proxy software or similar and you'd be set.

However, you'd need to replicate all data between the servers, so it wouldn't solve your original problem unless you split the storage load between the servers. You could make the servers share and access their storage over the network, or use another scheme - but that's all a lot more complicated than using a single, decent server.

Score:0
it flag

Besides adding additional disks to your server, there are a few other options available to you. You can use NFS to share folders over the network between the two servers. You can then have your PHP script either load balance between the two folders (the local one, and the remote NFS mount), or use a multi-layer filesystem like mergefs to make one folder balance the files between the two folders.

Another option is to store the location of each file in a database or lookup table, including what server it is on. You can then have a sub-path of your website proxy to your other server, or have a subdomain for each server.

The best option I can recommend of you would actually be having a NAS that you store all the files on, then mount on each of your servers using either NFS or SMB. A more complicated option would be to setup a distributed file share software like MinIO, GlusterFS or Ceph. However, these are probably more advanced then you need.


Examples

 ## NFS + mergefs

 server1.example.com
 
 /srv/
 |- local
 |  |- file1
 |  |- file2
 |
 |- remote --> nfs://server2.example.com/srv/local
 |  |- file3
 |  |- file4
 |
 |- combined ( /srv/local + /srv/remote )
 |  |- file1
 |  |- file2
 |  |- file3
 |  |- file4
 

 server2.example.com
 
 /srv/
 |- local
 |  |- file3
 |  |- file4
 |
 |- remote --> nfs://server1.example.com/srv/local
 |  |- file1
 |  |- file2
 |
 |- combined ( /srv/local + /srv/remote )
 |  |- file1
 |  |- file2
 |  |- file3
 |  |- file4


 ## One domain, subpath per server

 example.com
 |- usercontent/a
 |  |- file1
 |  |- file2
 |
 |- usercontent/b --> server2.example.com
 |  |- file3
 |  |- file4

 ## Subdomain per server

 example.com
 |- server1.example.com/files
 |  |- file1
 |  |- file2
 |
 |- server2.example.com/files
 |  |- file3
 |  |- file4
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.