-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support action-level concurrency in Java runtime. #130
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ | |
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ArrayBlockingQueue; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
@@ -48,7 +51,20 @@ public Proxy(int port) throws IOException { | |
|
||
this.server.createContext("/init", new InitHandler()); | ||
this.server.createContext("/run", new RunHandler()); | ||
this.server.setExecutor(null); // creates a default executor | ||
|
||
if (Boolean.parseBoolean(System.getenv("__OW_ALLOW_CONCURRENT"))) { | ||
ThreadPoolExecutor executor = new ThreadPoolExecutor( | ||
10, // Core size. | ||
25, // Max size. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we want to set the max pool size as this becomes a hard bound on the language when the openwhisk setting per function is defined elsewhere. So the user would have to know explicitly that for java they can't increase their concurrency past 25 without getting performance degradation even if they aren't cpu bounded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. This was basically an arbitrary setting on my part as I was moreso interested in getting something working. We could just as well set the max pool size to something else (or a configurable limit). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be a much larger change for the system to pass in the configured action limit as a part of the payload on the init request (and not every language would need the value so the system would need special logic per language for this). I think leaving it unbounded for now is probably the easiest way to get the initial working capability and can be optimized later if needed |
||
10 * 60, // Idle timeout. | ||
TimeUnit.SECONDS, | ||
new ArrayBlockingQueue<Runnable>(30) | ||
); | ||
executor.allowCoreThreadTimeOut(true); | ||
this.server.setExecutor(executor); | ||
} else { | ||
this.server.setExecutor(null); // Default executor. | ||
} | ||
} | ||
|
||
public void start() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how we should optimally determine this number since every function will have a different concurrency setting. Should it err on the side of maximizing low concurrency, i.e. most functions probably won't increase their setting past 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.