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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:23:35+00:00 2026-06-11T19:23:35+00:00

On my server side I use writable stream to record the changing data of

  • 0

On my server side I use writable stream to record the changing data of all the clients that are connected to the server. Here is what I wrote:

function updateLoop () {
    var data = {'timeStep': timeStep, 'playerInfo': playerInfo};
    var text = JSON.stringify(data);
    writeStram.write(text + '\n');
    timeStep += 1;
}
...
updateTimer = setInterval(updateLoop, 50);

So the function updateLoop() is called every 50ms.

It works when ‘playerInfo’ is small (less than 1KB), for example, after the server side running for 20s, there are 20*1000/50 = 400 lines of data in the output file

But when ‘playerInfo’ became larger, like 6KB or more, after the server side running for 20s, there only 220 lines of data in the output file. The larger playerInfo is, the lesser lines of successfully recorded data in the output file there is.

I am wondering if there is some limit to the calling rate of the method write()

Thanks a lot for your guys’ help!

  • 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-11T19:23:36+00:00Added an answer on June 11, 2026 at 7:23 pm

    The issue likely isn’t specifically with write, but with setInterval and how timers work in JavaScript.

    With the larger data, updateLoop is probably taking longer to finish executing than the set delay of 50 ms. If it take long enough that the intervals overlap each other, where one would be added to the event queue when another is already waiting, the newer interval is skipped (or “dropped”).

    How fast can the method write() of writable stream in node.js be called?

    write shouldn’t explicitly throttle performance, but it can be limited by the overall performance Node can achieve on your computer (affected by CPU, RAM, etc.).

    You’ll have to benchmark and compare the performance of updateLoop with varying amounts of playerInfo. There are a few packages you can use for this, including ben:

    ben(1000, updateLoop, function (ms) {
        console.log(ms, 'milliseconds per iteration');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use polling technique to notify clients about changes in server-side. So
I'm trying to use __doPostBack to pass some data from client to server side.
I'm trying to use the DataAnnotationsModelBinder in order to use data annotations for server-side
Say,how to implement these three steps: 1.fetch a html source from server side 2.use
Can I use the reverse geocoding server side, e.g. with a C# or C++?
Creating a server-side socket will fail if I'm trying to use the same port
i have a rhel 4 server and use php as a server side scripting
I am not sure how to use a single port at server side simultaneously
I want to use show a Loading Image on the click of server side
can we use server side controls in MVC, if no then why server side

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.