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

So, lets say I'm writing a web server and I want to support very
Am writing an application for iphone to run as mobile web server by assigning
I am writing a server application using Tornado web server . Application works with
I'm writing web application where I need to push data from server to the
I am writing a web server application in C# and using StreamReader class to
We're currently writing a web application based on a threaded python web server framework
I'm building an application that needs to use a web server like a file
I'm writing a web application using node.js & express to provide a real-time aprs
I'm writing a custom web server. When I enter the URL of my server
I'm writing a small web server for testing purposes using python, BasicHTTPServer and SimpleHTTPServer.

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.