Git Product home page Git Product logo

Comments (11)

sridatta avatar sridatta commented on July 20, 2024

I ran node-inspector and used the V8 profiler to identify what the bottleneck is. As I suspected, all the time was spent JSON.stringify-ing the chunks (which were ~40kB each).

What's the fix? We have considered ditching JSON and sending pure binary over the socket. Your issue may get us to seriously implement that.

from now.

tommedema avatar tommedema commented on July 20, 2024

@sridatta, thanks for the debuging. Sending pure binary over the socket would result in a huge improvement in general and allow me to use now.js for this project as well. I hope this will get implemented.

from now.

tommedema avatar tommedema commented on July 20, 2024

It looks like something like BSON would be great. I am not sure whether it has been used before with socket.io, but it sounds very promising.

from now.

dvv avatar dvv commented on July 20, 2024

msgpack?

from now.

tommedema avatar tommedema commented on July 20, 2024

@dvv, looks interesting. Pgriess made what seems to be a pretty worked out library for it, see https://github.com/pgriess/node-msgpack

from now.

dvv avatar dvv commented on July 20, 2024

yep. for i fear workaround techniques used in socket.io won;t allow for pure binary data traffic.

from now.

sridatta avatar sridatta commented on July 20, 2024

Wow, msgpack is impressive. we'll do some tests and use that for serialization if it's as good as they are claiming.

from now.

dvv avatar dvv commented on July 20, 2024

Hmm. On my node.js setup JSON.parse is faster than msgpack.unpack.

from now.

tommedema avatar tommedema commented on July 20, 2024

@dvv, really? That's quite disappointing.

It's a true shame that Websockets do not allow binary transfer.

In that case I will limit my now.js usage to action and short message broadcasts, while for binary transfers (eg. files) I will respond to normal get requests.

from now.

dvv avatar dvv commented on July 20, 2024

I suppose you should first benchmark your setup. Plus, I guess chances are that for your static assets you'd still use a dedicated server

from now.

ericz avatar ericz commented on July 20, 2024

We've given this issue a lot of thought, and unfortunately there does't seem to be a simple solution.

The chunks take a long time because they have to be read into memory and then deserialized. Since the client-server communication is not a true tcp socket, we can't avoid that. Additionally msgpack isn't going to make anything faster because the binary has to be based64'ed to be transported anyways.

No good solution to this issue guys, closing. If someone comes up with any ideas, feel free to reopen

from now.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.