How NodeJs resolve continuous operations?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I redirect to another webpage?What is the !! (not not) operator in JavaScript?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?
What action is recommended if your accommodation refuses to let you leave without paying additional fees?
Why has Speaker Pelosi been so hesitant to impeach President Trump?
Decision Variable Value from a Set (Gurobi)
How can Germany increase investments in Russia while EU economic sanctions against Russia are still in place?
Airport Security - advanced check, 4th amendment breach
Writing about real people - not giving offence
Can I bring this power bank on board the aircraft?
What's the correct way to determine turn order in this situation?
Why is there such a singular place for bird watching?
What does a textbook look like while you are writing it?
"Tenersi pronto" = to get ready or to be ready
Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?
Is the "spacetime" the same thing as the mathematical 4th dimension?
Could the Queen overturn the UK Supreme Court ruling regarding prorogation of Parliament?
Why not add cuspidal curves in the moduli space of stable curves?
Generating numbers with cubes
Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?
Why do Russians sometimes spell "жирный" (fatty) as "жырный"?
How are proofs normally constructed in a write up, in one line or split up into multiple lines?
Rank-one positive decomposition for a entry-wise positive positive definite matrix
Can a passenger predict that an airline or a tour operator is about to go bankrupt?
Looking for circuit board material that can be dissolved
Is there a way to replace Smite with Sharpness on a weapon?
Why did they use ultrafast diodes in a 50 or 60 Hz bridge?
How NodeJs resolve continuous operations?
How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I redirect to another webpage?What is the !! (not not) operator in JavaScript?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
There are Event Loop that accepts callbacks and executes them, when need. And If I understand this is one thread event loop, so there is one callback that it executes at a time. I write test
setInterval(() => console.log('INTERVAL'), 801);
setInterval(() => while(true) , 800);
There is the first setinterval()
that arrives at event loop firstly. Second setinterval()
(with infinite cycle) arrives secondly. So one thread executes while(true)
, and it cannot execute console.log('INTERVAL')
.
Is it means, if I F.E. will write server on NodeJs, that on one endpoint execute continuous calculations, and if one client sends the request, other clients should wait, until the server has served these long calculations and then will serve other clients?
P.S. in c# TPL, we use Tasks, and CLR thread pull creates two threads, and both of Console.WriteLine("Interval")
and 'while true' executes parallel.
javascript node.js
add a comment
|
There are Event Loop that accepts callbacks and executes them, when need. And If I understand this is one thread event loop, so there is one callback that it executes at a time. I write test
setInterval(() => console.log('INTERVAL'), 801);
setInterval(() => while(true) , 800);
There is the first setinterval()
that arrives at event loop firstly. Second setinterval()
(with infinite cycle) arrives secondly. So one thread executes while(true)
, and it cannot execute console.log('INTERVAL')
.
Is it means, if I F.E. will write server on NodeJs, that on one endpoint execute continuous calculations, and if one client sends the request, other clients should wait, until the server has served these long calculations and then will serve other clients?
P.S. in c# TPL, we use Tasks, and CLR thread pull creates two threads, and both of Console.WriteLine("Interval")
and 'while true' executes parallel.
javascript node.js
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44
add a comment
|
There are Event Loop that accepts callbacks and executes them, when need. And If I understand this is one thread event loop, so there is one callback that it executes at a time. I write test
setInterval(() => console.log('INTERVAL'), 801);
setInterval(() => while(true) , 800);
There is the first setinterval()
that arrives at event loop firstly. Second setinterval()
(with infinite cycle) arrives secondly. So one thread executes while(true)
, and it cannot execute console.log('INTERVAL')
.
Is it means, if I F.E. will write server on NodeJs, that on one endpoint execute continuous calculations, and if one client sends the request, other clients should wait, until the server has served these long calculations and then will serve other clients?
P.S. in c# TPL, we use Tasks, and CLR thread pull creates two threads, and both of Console.WriteLine("Interval")
and 'while true' executes parallel.
javascript node.js
There are Event Loop that accepts callbacks and executes them, when need. And If I understand this is one thread event loop, so there is one callback that it executes at a time. I write test
setInterval(() => console.log('INTERVAL'), 801);
setInterval(() => while(true) , 800);
There is the first setinterval()
that arrives at event loop firstly. Second setinterval()
(with infinite cycle) arrives secondly. So one thread executes while(true)
, and it cannot execute console.log('INTERVAL')
.
Is it means, if I F.E. will write server on NodeJs, that on one endpoint execute continuous calculations, and if one client sends the request, other clients should wait, until the server has served these long calculations and then will serve other clients?
P.S. in c# TPL, we use Tasks, and CLR thread pull creates two threads, and both of Console.WriteLine("Interval")
and 'while true' executes parallel.
javascript node.js
javascript node.js
edited Mar 29 at 8:59
Muath
2,73410 gold badges32 silver badges59 bronze badges
2,73410 gold badges32 silver badges59 bronze badges
asked Mar 28 at 21:09
AndriyAndriy
133 bronze badges
133 bronze badges
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44
add a comment
|
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44
add a comment
|
2 Answers
2
active
oldest
votes
yes, server hangs if one endpoint is performing complex computations and if other endpoint requests, it must wait. Node has only one event loop and limited number of worker threads
You should not block the event loop. you should not perform the complex computations in node js synchronously or asynchronously.
Please refer this for more information:
https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
add a comment
|
Don't use while(true)
Use this instead:
setInterval(() => console.log('INTERVAL1'), 801);
// change 1000ms with time you need
setInterval(() => setInterval(() => console.log('INTERVAL2'), 1000) , 800);
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
add a comment
|
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/4.0/"u003ecc by-sa 4.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%2f55406880%2fhow-nodejs-resolve-continuous-operations%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
yes, server hangs if one endpoint is performing complex computations and if other endpoint requests, it must wait. Node has only one event loop and limited number of worker threads
You should not block the event loop. you should not perform the complex computations in node js synchronously or asynchronously.
Please refer this for more information:
https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
add a comment
|
yes, server hangs if one endpoint is performing complex computations and if other endpoint requests, it must wait. Node has only one event loop and limited number of worker threads
You should not block the event loop. you should not perform the complex computations in node js synchronously or asynchronously.
Please refer this for more information:
https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
add a comment
|
yes, server hangs if one endpoint is performing complex computations and if other endpoint requests, it must wait. Node has only one event loop and limited number of worker threads
You should not block the event loop. you should not perform the complex computations in node js synchronously or asynchronously.
Please refer this for more information:
https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
yes, server hangs if one endpoint is performing complex computations and if other endpoint requests, it must wait. Node has only one event loop and limited number of worker threads
You should not block the event loop. you should not perform the complex computations in node js synchronously or asynchronously.
Please refer this for more information:
https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
answered Mar 29 at 7:50
Shekar ManiaShekar Mania
793 bronze badges
793 bronze badges
add a comment
|
add a comment
|
Don't use while(true)
Use this instead:
setInterval(() => console.log('INTERVAL1'), 801);
// change 1000ms with time you need
setInterval(() => setInterval(() => console.log('INTERVAL2'), 1000) , 800);
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
add a comment
|
Don't use while(true)
Use this instead:
setInterval(() => console.log('INTERVAL1'), 801);
// change 1000ms with time you need
setInterval(() => setInterval(() => console.log('INTERVAL2'), 1000) , 800);
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
add a comment
|
Don't use while(true)
Use this instead:
setInterval(() => console.log('INTERVAL1'), 801);
// change 1000ms with time you need
setInterval(() => setInterval(() => console.log('INTERVAL2'), 1000) , 800);
Don't use while(true)
Use this instead:
setInterval(() => console.log('INTERVAL1'), 801);
// change 1000ms with time you need
setInterval(() => setInterval(() => console.log('INTERVAL2'), 1000) , 800);
answered Mar 28 at 22:15
MuathMuath
2,73410 gold badges32 silver badges59 bronze badges
2,73410 gold badges32 silver badges59 bronze badges
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
add a comment
|
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
It's not a question about what to use, it is a question about what occurs if one client on my Node Js server sends the request that will be processed too long. Will other clients wait until the server serve the first client? And why, then, node js called a super backend language?
– Andriy
Mar 29 at 6:58
add a comment
|
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.
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%2f55406880%2fhow-nodejs-resolve-continuous-operations%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
each 801 milliseconds the console will display 'INTERVAL' example jsfiddle.net/t016czrL
– Muath
Mar 28 at 21:19
@Muath but if setInterval with the infinite loop will be first in the event loop, so that alert will never display: jsfiddle.net/4vmcwrqg
– Andriy
Mar 28 at 21:44