Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6198751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:04:13+00:00 2026-05-24T04:04:13+00:00

When writing a web server application with node.js it is of course very important

  • 0

When writing a web server application with node.js it is of course very important to never block the main thread. But what if a server request needs to do calculations that will take some time to complete?

Will doing a

setTimeout(myCalculationFunc(), 0);

be the best way of keeping the server responding to other requests?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:04:13+00:00Added an answer on May 24, 2026 at 4:04 am

    I created as simple example using child_process to do heavy calculating if you would like to use it.

    You can do it like this:

    var http = require("http"),
    exec = require("child_process").exec;
    
    http.createServer(function(request, response) {
        var endvalue;
        request.on('data',
        function(data) {
            endvalue = data;
        });
        request.on('end',
        function() {
            exec("node calculate.js "+endvalue,
                function (error, stdout, stderr) {
                  response.writeHead(200, {"Content-Type": "text/plain"});
                  response.write(stdout);
                  response.end();
                });
        });
    }).listen(8080);
    

    Calculate.js:

    var endvalue = process.argv[2];
        for (i=0;i<=endvalue;i=i+1)
        {
            //just keeping it busy
        }
    console.log("FINISHED USING ENDVALUE: "+endvalue);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a web server application in C# and using StreamReader class to
I am writing a web server in Java and I want it to support
I'm writing a web-server in Python as a hobby project. The code is targeted
I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass
I'm writing a shell script to do some web server configuration. I need to
i having task to upload file to Web application server, when test with local
I'm writing a web application in Symfony for the first time, so I have
We are writing an application for Android OS which communicates with a server to
I have a web application that loads some 50 tables from SQL Server into
I'm trying to add log4net logging to a web application I'm writing. I've got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.