0

I don't have any experience with servers and want to know how should I manage this situation:

My system get files,hash them and then send them back so when you post a file to it,it should hash it and then give you a download link.

It is so simple if I have 1 user but what should I do when in web page I have a list that you can add many files and files will done one by one?
This one is simple too,I could make a cgi (or what ever it needs,cgi is an example) per requests,do the job and update the page with Ajax but what will happen when multi users come together?

for example 10 user come and each add 20 file in the list. Should I open a cgi for each request? In this case I get 200 live cgi that are hashing in the same time.
It seems not good especially when users count will increase.

How can I manage this situations that multi users come and give multi task and should wait for them to finish?

There is not any especial limit in language or theology and I interested in architecture.

user3656830
  • 63
  • 1
  • 7

2 Answers2

0

Yes, you use a separate thread for each request. This is how web servers work.

Multi-threaded programming is hard, and easy to mess up. Please use a web programming framework, whatever your language, I'm sure a web-programming framework already exists that abstracts the threading issues.

As you scale up, yes, you will need more threads, but then you do things like add more servers and put it behind a load-balancer. Please test how much load your server can handle before you bother with that kind of architecture though, modern servers can handle quite a bit of load.

Rob Conklin
  • 8,806
  • 1
  • 19
  • 23
  • Thanks.So you say I should make a thread for each user so when 1000 user come I will have 1000 thread working?I want to make it with cgi or php or I can make a multi threaded system in pascal that the cgi or php use it and host them in Apache.What you think?Should not I use a limited system (for example 10 simultaneously work max) and a request system so one call for add request and get a ticket number and go back and call check with number for getting status?I hope you understand what Im saying. – user3656830 Nov 09 '15 at 14:51
  • Apache already creates a thread for each user, that same OS thread will be used for PHP. Apache has ability to limit the number of concurrent threads: http://stackoverflow.com/questions/3389496/how-do-you-increase-the-max-number-of-concurrent-connections-in-apache But I don't recommend you poke at this unless you know what you are doing. – Rob Conklin Nov 09 '15 at 15:10
  • If you really have 1000 concurrent users, you need to look at the load balancer solution that I talked about in my answer. – Rob Conklin Nov 09 '15 at 15:12
0

I choose a system that with a main service and cgi calls will add requests to a data base and main service will check it and do the tasks and other cgi calls can check status and get the result.

Also Service will use a multi thread queue system to handle simultaneously tasks.

I can make it without DB but DB helps to keep a log and make it easier to manage.

If any one have a better idea please share.

user3656830
  • 63
  • 1
  • 7