简体   繁体   中英

processing requests when we have multiple requests from multiple customers

I'm developing node service on heroku platform , this service will accept requests from different clients but can process only 10 requests at a time. After receiving request we will write into database then process 10 at a time. when multiple sends requests to this service and I want to split the threads equally among customers. for example customer A sends 10k requests , B sends 5K requests and C sends 100 requests.

  1. We need to split threads for 3 customers equally. 2.After completing customer C requests , I want to allocate threads available equally to A and B. 3.After B completion , only to A.
  2. If we receive requests for any other customers , we need to split threads. Can anyone help me to write this algorithm.

Thanks

In node JS we can use process environment variable . Using process Env variable you can identify how many ports should be used by one process and if more request you will get you can decrease the variable value and if some process completed then you can increase the variable value.

process.env.variable_name = 'Value';

You can access this value in any process and update in any process. Value for this process always the same for all process.

console.log(process.env.variable_name);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM