r/MetaSim • u/aaron_ds • Jan 08 '14
MetaSim API 1.0 Draft 2 In Progress
Hi, I started working on a draft 2 for the MetaSim API.
One of the big unresolved and potential problems was how could clients efficiently receive simulation updates. In draft 1, the only option was to poll, and hope that the server implemented some for of caching or ETags or If-Modified-Since. That didn't seem like the best solution so I've added the ability to subscribe to changes through WebSockets.
I've updated the API document with a means to receive notifications using WebSockets. This solves a few problems:
- How can the server detect that the simulation is being viewed so that it can only iterate when the simulation is being viewed? (It's costly if someone were to create a simulation then leave when it is running in the background and chewing up resources indefinitely.)
- How can the client receive simulation updates (images especially)? Polling is inefficient and is a source of latency.
- How can engines receive simulation updates from other engines. An engine may want to wait to iterate until all of the engines it depends on for data have iterated. Polling, once again, is too inefficient for this and an even bigger source of latency.
Right now only the Body resource supports notifications, this assumes that bodies (planets, stars, etc.) are not created or destroyed for the lifetime of the simulation. We haven't really come to a decision about the scope of MetaSim simulations in terms of time, so I'm guessing that geologic timescales are ok, but universal timescales are too big for right now.
As always, I'm interested in feedback. The link to the MetaSim 1.0 Draft 2 is https://docs.google.com/document/d/16i6js1x-AFMwsWKfl1aKphYR2p8puRb3ldp8kXH9Z8Q/edit?usp=sharing The Notification resource is new and the Body resource has been updated.
View all comments
Show parent comment
1
u/ion-tom Jan 16 '14
Interesting thought, maybe running directly on AWS would be beneficial, but then of course comes cost. I know it's a beast of a question to pose, but what would it take to implement P2P, something like BOINC? They've got to have a method of duality for safe processing since grid points would turn on and off all the time.
You could use BOINC as a failsafe, and then use multiple cloud services to switch temporarily until Heroku comes back online? Of course that level of infrastructure migthe be overkill, but I think using BOINC for slow stream process might be really effective. You could even monetize it with a clone of Gridcoin. We could call it "Simcoin" or something, and allow people to "mine it" or buy it, and then use it to purchase more MetaSim instances. Sure beats the DLC monetization strategy anyway.
Do you know of any libraries that would be a good reference here? I mean, any type of "paint" type service with Canvas could work. Also, doesn't three.js allow video textures? We would need some type of library that could maybe treat the image as a low framerate movie, with a prerender just sitting there as an image but having slow updates or something. At least tossing the data from server to server could have an easy format:
pix{objid,layer,x,y,r,g,b} where x and y are the dimensions of the texture not the object location.
Do you think client to client messaging could help address this? Instead of passing everything centrally I mean. I guess you could still route and push through the central API without the renderer, but maybe we need an additional layer between the central object system and the renderer itself? So MetaSimHub as its own repository for routing between engines, which would then communicate a concise definition to the renderer (WebHexPlanet or something else). This will be required for multi-engine experiences I think, but it doesn't seem like your API would need to be adjusted too much for that to work. If we're lucky we could even see people using multiple WebGL platforms on your same API, you'd just have to build compatibility into newer versions.