Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-11

Manage server task list architecture

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aradeonas

Hi, This is not an especially Lazarus or FPC question but I want to do it with Lazarus so I need your help.

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?

Regards, Ara

http://www.fastmail.com - Or how I learned to stop worrying and love email again -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151108/3b453b9f/attachment.html>

Reply by email

Mattias Gaertner
to Aradeonas
Show quoted text 16 lines
[...] 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 long does it take to hash the 200 files?

Mattias

Reply by email

Michael Van Canneyt
to Aradeonas
Aradeonas wrote
Any idea?

I would create a scheduler process which runs in the background.

1. The scheduler process processes the jobs, which are waiting in a queue.
2. Jobs are submitted to the queue using fastcgi or cgi.
3. Each job gets a unique identifier, which you receive when the job is submitted.
4. The identifier can be used to poll for the job status.
5. As soon as the job is finished, the result can be downloaded, and then the job is removed from the queue.
6. Jobs too long in the queue are removed by the scheduler.

Michael.

Reply by email

Aradeonas
to Michael Van Canneyt

I think like you but I doubted that is a good idea but now you have the same idea so it should be good.
So I want to ask some question:
What is the best approach to make a connection between cgi and service? Do you have any idea for users in the queue?
for example user1 and 100 request and user2 add 100 and so on. so user n should wait until all other users tasks finish and I dont like it and I think it is better when we have n user in each time it should do one user task per time.So what is the better way to sort the queue so it done user1task1 userttask2 user1task2 user2task2 and ....?

Regards,
Ara

http://www.fastmail.com - The professional email service

Reply by email

Michael Van Canneyt
to Aradeonas
Aradeonas wrote
I think like you but I doubted that is a good idea but now you have the same idea so it should be good. So I want to ask some question: What is the best approach to make a connection between cgi and service?

It can be as simple as files in a directory.
It can be as difficult as records in a database.

Do you have any idea for users in the queue? for example user1 and 100 request and user2 add 100 and so on.

If you use files :
One directory per user, one file per task in the directory. loop over user directories,
and always process only 1 file per user dir in the loop.

in sql that would be

select userid,min(task) from tasks where tasks.done=0 group by userid

for a table, for example
create table tasks(
userid varchchar(100),
task int,
done int,
taskdata mydatatype
);

Michael.

Reply by email