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 8436883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:18:09+00:00 2026-06-10T07:18:09+00:00

I came across node.js and python’s tornado vs the Apache . They say :

  • 0

I came across node.js and python's tornado vs the Apache.

They say :

  • Apache makes a thread for every connection.
  • Node.js & tornado actually does event looping on a thread and a single thread can handle many connections.

I don’t understand that what logically be a child of a thread.
In computer science terms:

  • Processes have isolated memory and share CPU with context switches.
  • Threads divides a process.
  • Therefore, a process with multiple control points is achieved by multiple threads.

Now,

What how does event loop works under a thread ?

How can it handle different connection under 1 control of a thread ?

Update :

I mean if there is communication with 3 sockets under 1 thread, how can 1 thread communicate with 3 sockets without keeping anyone on wait ?

  • 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-06-10T07:18:10+00:00Added an answer on June 10, 2026 at 7:18 am

    An event loop at its basic level is something like:

    while getNextEvent (&event) {
        dispatchEvent (&event);
    }
    

    In other words, it’s nothing more than a loop which continuously retrieves events from a queue of some description, then dispatches the event to an event handling procedure.

    It’s likely you know that already but I’m just explaining it for context.

    In terms of how the different servers handle it, it appears that every new connection being made in Apache has a thread created for it, and that thread is responsible for that connection and nothing else.

    For the other two, it’s likely that there are a “set” number of threads running (though this may actually vary based on load) and a connection is handed off to one of those threads. That means any one thread may be handling multiple connections at any point in time.

    So the event in that case would have to include some details as to what connection it applies to, so the thread can keep the different connections isolated from each other.

    There are no doubt pros and cons to both options. A one-connection-per-thread optio n would have simplified code in the thread function since it didn’t have to deal with multiple connections but it may end up with a lot of resource usage as the load got high.

    In a multiple-connection-per-thread scenario, the code is a little more complex but you can generally minimise thread creation and destruction overhead by simply having the maximum number of threads running all the time. Outside of high-load periods, they’ll just be sitting around doing nothing, waiting on a connection event to be given to them.

    And, even under high load, it may be that each thread can quite easily process five concurrent connections without dropping behind which would mean the one-connection-per-thread option was a little wasteful.


    Based on your update:

    I mean if there is communication with 3 sockets under 1 thread, how can 1 thread communicate with 3 sockets without keeping anyone on wait ?

    There are a great many ways to do this. For a start, it would generally all be abstracted behind the getNextEvent() call, which would probably be responsible for handling all connections and farming them out to the correct threads.

    At the lowest levels, this could be done with something like a select call, a function that awaits activity on one of many file descriptors, and returns information relating to which file descriptor has something to say.

    For example, you provide a file descriptor set of all currently open sockets and pass that to select. It will then give you back a modified set, containing only those that are of interest to you (such as ready-to-read-from).

    You can then query that set and dispatch events to the corresponding thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this thread Node.js HTTPS Secure Error which mentions that the tls
I've been using socket.io with node.js and came across Nowjs , it seems this
I came across the following code : int i; for(; scanf(%s, &i);) printf(hello); As
I'm starting with node expressjs framework and I came across this problem I can't
Came across this conditional in some uncommented Objective-C code: if (w & (w -
I came across dynamically typed python, statically typed f#, strongly typed C++ and weakly
I came across this piece of Java function to convert an XML node to
I just came across the following commit on GitHub: https://github.com/felixge/node-formidable/commit/0a0b150668daa3c6f01626d2565b898e5da12392 How does one go
Came across this handy regular expression utility in Python (I am a beginner in
I'm studying node.js and came across this example in the node.js manual: ... var

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.