java - Using Executors in very high-load enviroment -


i manage write rest api using stripe framework. inside api, have several tasks need execute , combine results. come approach, borrowed javascript, spawn tasks several threads , join rather chronological implementation. thus, used executorservice found bottleneck on implementation when number of requests quite big, tasks finished on longer time expect.

my question related alternate way achieve same purpose.

  1. how can create executors per request
  2. how can expand executors' size

to demonstrate, let consider way on javascript

import promise 'bluebird'; let tasks = []; tasks.push(task01); tasks.push(task02); promise.all(tasks).then(results => { do_sth_here!} ) 

bring idea java, have implemented below

executorservice exec = executors.newcachedthreadpool(); list<callable<promise>> tasks = new arraylist<>(); list<future<promise>> promiseall;  try {     tasks.add(() -> taskpromises(input));     tasks.add(() -> taskpromise(input));     promiseall = exec.invokeall(tasks);     (future<promise> fr : promiseall) {         // do_some_thing_next     }            } 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

linux - Why does bash short curcuit fail in crontab? -