Giter Club home page Giter Club logo

gossip_gleamers's Introduction

gossip_gleamers

My attempt at Gossip Glomers

Run

Expect Maelstrom v0.2.3 to aleady have been downloaded and unzipped.

gleam run -m gleescript # export project as escript

./maelstrom/maelstrom test -w echo --bin ./gossip_gleamers --node-count 1 --time-limit 10 # test echo load
./maelstrom/maelstrom test -w unique-ids --bin ./gossip_gleamers --time-limit 30 --rate 1000 --node-count 3 --availabil
ity total --nemesis partition # unique ids load

You may need to install other Maelstrom dependencies, such as openjdk,graphviz and gnuplot

Development

gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell

Writeup

Challenge 1: Echo

Biggest challenge here is to figure out the intricacies of Gleam's JSON library and getting my dev environment set up in order to run Gleam with Erlang 27.

The use syntactic suger together with result.try makes for rather elegant looking code.

Challenge 2: Unique ID Generation

The approach taken is a signed 32-integer version of Snowflake ID. The challenge parameter is 1000 qps for 30s, which roughly translates to 1 ID/ms.

timestamp node id sequence no. total
17 6 8 31

Since the node is assigned an ID during initialization, we do not have to account for network partiitons, since there is no communication between the nodes anyway.

Main downside here is the timestamp bits, which can only contain 2.19mins of runtime before overflowing. Additionally, it is unlikely to start from 0.

One improvement would be to readjust the bits allocated for timestamp and sequence no. Given the relatively low QPS, the sequence number is unlikely to require so many bits.

Another improvement is to include overflow checks for sequence number and timestamp during the ID generation itself.

gossip_gleamers's People

Contributors

dingyuchen avatar

Watchers

 avatar

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.