One Billion Cells – Another Multiplayer Demo with Clojure

(cells.andersmurphy.com)

49 points | by adityaathalye 11 hours ago ago

18 comments

  • andersmurphy 9 hours ago

    Oh, fun. I wasn't expecting this on here so soon. It's very MVP and currently running on a 5$ VPS.

    Happy to answer any questions.

    • andersmurphy 7 hours ago

      And we're back on a 10$ VPS.

      • konsalexee 7 hours ago

        What is the full stack you are using? What parts also require scaling up? DB, bandwidth orrr?

        • andersmurphy 7 hours ago

          So the stack is datastar + clojure + sqlite + caddy on a hetzner VPS 2 core 2G.

          The scaling was preemptive as it was hitting 150% CPU (out of 200%). Needed to power down to rescale.

          Now it's hovering at around 200% (out of 400%). About 80kb/s and 10 disk iops.

          Everything goes via a sqlite db.

          • daymanstep 6 hours ago

            How are you doing the throttling? I imagine one malicious player might do like 10000 iops to your DB.

            • andersmurphy 6 hours ago

              So there's no rate limiting.

              But because it's sqlite it's a single writer. Everything gets batched as one transaction every 100ms. The operations on a single chunk gets squashed into a single write.

              Even without the squashing sqlite can handle 10000-20000+ updates/s because of the transaction batching.

              With the chunk based squashing all edits to a chunk in that 100ms window become one update, so it can scale quite well.

              • matsemann 6 hours ago

                But the question wasn't really if you can handle it, but more if someone could control the whole board themselves, I think?

                • andersmurphy 6 hours ago

                  Oh, I mean they could try. It's a very big board. Probably possible though if someone is sufficiently motivated.

                  • matsemann 5 hours ago

                    I see a snake eating the 0,0 part now at least, heh.

                    Btw, if I add a ' to the string, it's impossible to override by othrs. At least in the UI on Firefox, the snake still ate it.

    • spintin 7 hours ago

      [dead]

  • amadeuspagel 5 hours ago

    On mobile, when I click on one of the cells, my keyboard opens.

    • andersmurphy 5 hours ago

      So that you can type in the field. It does shift the layout which is annoying.

      I put this together in a day and wasn't planning on it being on HN. So there's definitely some jank/UX polish.

      For example the typing experience is nicer on chrome as the field sizes to the text.

  • Theofrastus 5 hours ago

    Has someone already animated Bad Apple on there?

    Or played Doom, for that matter.

    • andersmurphy 5 hours ago

      I'm just heading off on holiday so if someone does... Please make a gif so I can watch it on my return.

      There's a bad apple demo on the datastar site. Datastar's[1] streaming hypermedia is what makes this possible, that and good old Clojure and sqlite.

      - [1] https://github.com/starfederation/datastar

      • aquariusDue 2 hours ago

        Datastar is amazing, I can't wait for the next big release.

        Once everything clicks it becomes a force multiplier and a joy to work with, something that helped me in that regard is throwing a "data-json-signals" on an element so its easier to keep an eye on things.

    • fambalamboni 5 hours ago

      [dead]

  • freilanzer 5 hours ago

    What the hell am I even looking at?

  • fambalamboni 5 hours ago

    [dead]