Giter Site home page Giter Site logo

RequestId about gotalk HOT 5 CLOSED

rsms avatar rsms commented on July 30, 2024
RequestId

from gotalk.

Comments (5)

gtaylor avatar gtaylor commented on July 30, 2024

Selfishly, I'd love to be able to use UUIDs, but that may be overkill. In either case, we're not talking about a massive amount of overhead (3 vs 4 bytes, or 3 vs 16 bytes for UUID). I'm still not 100% sure how the request IDs should be generated, but I'd definitely want to avoid collisions.

from gotalk.

alimoeeny avatar alimoeeny commented on July 30, 2024

Using UUIDs sounds like a good idea. Not having collisions over long periods of time over different communication channels can open unexpected possibilities.

from gotalk.

rsms avatar rsms commented on July 30, 2024

TL;DR: 3 bytes (16 777 216 values) is enough.

3 bytes is simply enough for anything I could imagine. If you have an application which might send more than 16 777 215 requests in between a request being sent and responded to, you might want to use two or more connections (one for the very very slow requests and one for the very high-frequency requests.)

The ID has the potential to express 16 777 216 values, while the current Go and JS implementations only use 46 655 values (base-36 encoded integer.) UUID does not only require a large number of bytes to be represented, it is also expensive to calculate (needs a pool of true random data, etc.) Incrementing an integer is very cheap and easy to implement.

Is there a scenario you have in mind where an application might perform 16 777 216 requests in such a close succession that the first request does not have time to complete before the 16 777 217th request is sent?

from gotalk.

funny-falcon avatar funny-falcon commented on July 30, 2024

46655 certainly not enough. Use at least base64 if you wish to use text only id.

Lets calc: 1000000rps of light requests and 1 request which lasts 17 seconds - then 16M will not be enough either. Yes, it is strange combination, but 4 bytes is 256 times more reliable.

from gotalk.

rsms avatar rsms commented on July 30, 2024

v1 landed in master and the protocol now uses 4 bytes for requestID

from gotalk.

Related Issues (10)

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.