threefoldtecharchive / 0-robot

Distributed live cycle management system
Apache License 2.0
0 stars 0 forks source link

Replace uuid with a smaller ID #27

Open rkhamis opened 6 years ago

rkhamis commented 6 years ago

Issue migrated from [https://api.github.com/repos/zero-os/0-robot/issues/66](), opened by @zaibon

Currently we use uuidv4 for most of the ID of the object we store (services, tasks,...) uuid is nice but it's a pretty big number and since we keep a lot of these object in memory, something with a smaller memory footprint would be nice.

We still need a ID that is has these properties:

After a bit a research I found snowflake from twitter: https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html This seems like +- what we need, but snowflake requires quite some infrastructure to work.

Then I found simpleflake: https://web.archive.org/web/20140420064035/http://engineering.custommade.com/simpleflake-distributed-id-generation-for-the-lazy/

Which seems to be a perfect fit.

There is python implementation : https://github.com/SawdustSoftware/simpleflake

rkhamis commented 6 years ago

*commented by @muhamadazmy I was gonna suggest generating our own IDs based on the timestamp + robot id + sequence number then while reading the links, i found out that is exactly what snowflake does.

I couldn't check the simpleflake docs it doesn't open, not sure the site is down or blocked. Also no api docs, not quite sure how it works internally to make an opinion.

I totally understand your concern about the size of the IDs, but honestly I don't think it's the IDs that will have a dramatic impact on the memory, it would be the actual service data.

May be if we can map the in memory structures to a small database on the file-system, and only cache the services that have been recently accessed, or similar approaches to keep the data on disk (memory map may be?) it would be better for the host memory.*