Vertx http server only creating one instance
I am creating a simple micro service using vertx and when i start my server it only create one event thread when available is 12.
My code to start server is
public static void main(String args)
Vertx vertx = Vertx.vertx();
int processorCounts = Runtime.getRuntime().availableProcessors();
DeploymentOptions options = new DeploymentOptions().setInstances(processorCounts);
vertx.deployVerticle( HttpRouter.class.getName(),options);
And my http router looks like this
@Override
public void start() throws Exception
super.start();
Router router = Router.router(vertx);
router.get("/").handler(event ->
event.response().end("Hello World");
);
vertx.createHttpServer().requestHandler(router::accept).listen(8001);
java vert.x
add a comment |
I am creating a simple micro service using vertx and when i start my server it only create one event thread when available is 12.
My code to start server is
public static void main(String args)
Vertx vertx = Vertx.vertx();
int processorCounts = Runtime.getRuntime().availableProcessors();
DeploymentOptions options = new DeploymentOptions().setInstances(processorCounts);
vertx.deployVerticle( HttpRouter.class.getName(),options);
And my http router looks like this
@Override
public void start() throws Exception
super.start();
Router router = Router.router(vertx);
router.get("/").handler(event ->
event.response().end("Hello World");
);
vertx.createHttpServer().requestHandler(router::accept).listen(8001);
java vert.x
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09
add a comment |
I am creating a simple micro service using vertx and when i start my server it only create one event thread when available is 12.
My code to start server is
public static void main(String args)
Vertx vertx = Vertx.vertx();
int processorCounts = Runtime.getRuntime().availableProcessors();
DeploymentOptions options = new DeploymentOptions().setInstances(processorCounts);
vertx.deployVerticle( HttpRouter.class.getName(),options);
And my http router looks like this
@Override
public void start() throws Exception
super.start();
Router router = Router.router(vertx);
router.get("/").handler(event ->
event.response().end("Hello World");
);
vertx.createHttpServer().requestHandler(router::accept).listen(8001);
java vert.x
I am creating a simple micro service using vertx and when i start my server it only create one event thread when available is 12.
My code to start server is
public static void main(String args)
Vertx vertx = Vertx.vertx();
int processorCounts = Runtime.getRuntime().availableProcessors();
DeploymentOptions options = new DeploymentOptions().setInstances(processorCounts);
vertx.deployVerticle( HttpRouter.class.getName(),options);
And my http router looks like this
@Override
public void start() throws Exception
super.start();
Router router = Router.router(vertx);
router.get("/").handler(event ->
event.response().end("Hello World");
);
vertx.createHttpServer().requestHandler(router::accept).listen(8001);
java vert.x
java vert.x
edited Nov 14 at 19:50
Chirdeep Tomar
1,11521645
1,11521645
asked Nov 11 at 17:47
Lakshay Jain
185213
185213
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09
add a comment |
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09
add a comment |
1 Answer
1
active
oldest
votes
What is your process for testing? I assume you opened a browser and hit refresh on the same page. Then yes, the same verticle instance will handle the requests. The reason is Vert.x load balances connections among verticles instances, not requests.
Open a different browser and you should see different event loop names.
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251493%2fvertx-http-server-only-creating-one-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What is your process for testing? I assume you opened a browser and hit refresh on the same page. Then yes, the same verticle instance will handle the requests. The reason is Vert.x load balances connections among verticles instances, not requests.
Open a different browser and you should see different event loop names.
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
|
show 2 more comments
What is your process for testing? I assume you opened a browser and hit refresh on the same page. Then yes, the same verticle instance will handle the requests. The reason is Vert.x load balances connections among verticles instances, not requests.
Open a different browser and you should see different event loop names.
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
|
show 2 more comments
What is your process for testing? I assume you opened a browser and hit refresh on the same page. Then yes, the same verticle instance will handle the requests. The reason is Vert.x load balances connections among verticles instances, not requests.
Open a different browser and you should see different event loop names.
What is your process for testing? I assume you opened a browser and hit refresh on the same page. Then yes, the same verticle instance will handle the requests. The reason is Vert.x load balances connections among verticles instances, not requests.
Open a different browser and you should see different event loop names.
answered Nov 17 at 8:40
tsegismont
3,0251718
3,0251718
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
|
show 2 more comments
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
Actually i am getting more clearity on how verticles work. As per my understanding there is only one event thread and that load balances between all verticles because i sleeped thread in one of verticle and it stopped accepting any more request. Is my assumption correct?
– Lakshay Jain
Nov 17 at 15:04
NEVER block the event loop!
– user924272
Nov 18 at 0:50
NEVER block the event loop!
– user924272
Nov 18 at 0:50
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@LakshayJain No, your assumption is incorrect. There are different event loop threads (by default 2*number of cores). But each verticle is assigned a single event loop. So, when you deploy multiple verticle instances, each instance gets its own event loop. And Vert.x load balances HTTP connections between them.
– tsegismont
Nov 19 at 9:26
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
@tsegismont: You are correct there is one thread blocked for each browser. So how can i resolve this so that each browser use multiple threads?
– Lakshay Jain
Nov 19 at 16:01
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
No thread is "blocked". Browsers use persistent HTTP connections so after you opened a tab the same verticle will handle requests from that page. Your users will use different browsers of course :)
– tsegismont
Nov 19 at 19:21
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251493%2fvertx-http-server-only-creating-one-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This might give you answers: stackoverflow.com/questions/40709931/…
– Quintium
Nov 14 at 20:27
@Quintium I have gone through documentation and i m familiar with concept that each verticle by default is on one event thread thats why i set number of instances for a verticle but only one verticle is handling all my requests.
– Lakshay Jain
Nov 15 at 5:13
It's looking like no different what I have done in tests myself. How you determine it? Looking current thread name in handler code?
– Quintium
Nov 16 at 17:45
@Quintium Actually verticles instances are launched but event thread is one so if any verticle block it then no more request is processed. So shall i use rxjava to create new threads or use blockingHandler ?
– Lakshay Jain
Nov 17 at 19:09