Serving static files


Today, modern web applications needed static files to serve users. There are many kinds of files: music, videos, archives, documents, or any type. A basic functions:

  1. Users can upload his/her file to the server
  2. Users can download/view files

There are plenty of solutions in terms of framework or programming language. In PHP, files store in the same directory of codes. The Django project, it has its own library to serve files. There was a ready solution for beginners/startups for not worrying about serving the files. The size of the project is small and the number of static files is not huge, that's okay, it will work as expected.

Let's think about a project with a large scope with files and low latency.

1-option: 3rd party solution: AWS S3.

S3 server is basically, a solution by Amazon, it has packages for famous languages to use its API: to upload/delete the file. And your files are stored in AWS servers and you do not worry about load balancing, backup, and so on. But, you need to pay for bandwidth, for example, your files are mostly are videos, you need to pay money per downloaded GB. If you need with low latency of files, even you can integrate with AWS Cloudfront. It is basically, cached files in with different regions around the world.

2-option: 3rd party free software: Minio

Minio is a package serving the files same as AWS S3 structure but in your server. You need to use a Docker container to run Minio. Now, you do not worry about AWS prices. But, you need to be aware of backups, system crashes and pays for traffic for your server provider. If you have files in AWS S3, you can copy all files to own minio server. Here simple docker-compose file to test in local machine: docker-compose.yml

To start run the following command: docker-compose up -d.

3-option: Recently, Cloudflare launched its object storage service at a very inexpensive price.

For now, I know those solutions, if you have a better approach, let me know in the comments.

Comments