Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to build a website that will (eventually) work on Mars, v1.1.0, WebCamp Zagreb 2016

How to build a website that will (eventually) work on Mars, v1.1.0, WebCamp Zagreb 2016

Slobodan Stojanović

October 29, 2016
Tweet

More Decks by Slobodan Stojanović

Other Decks in Programming

Transcript

  1. #wczg
 @slobodan_ I am Slobodan Stojanović CTO of Cloud Horizon

    and JS Belgrade Meetup organizer github.com/stojanovic twitter.com/slobodan_ 2
  2. #wczg
 @slobodan_ WARNING The main goal of this talk is

    to explore some of the new technologies in a bit unexpected way, most of those things will probably work completely different at the moment humans colonize Mars. This is not deep technical talk and it contains some level of simplified facts.
  3. #wczg
 @slobodan_ • It’s a planet • Approximately the same

    landmass with Earth • Mars day (Sol) is 1d 0h 40m • Mars year is 687 days (1.9 years) • Temperature can be 20°C • Martian surface gravity is only
 37% of the Earths • There are signs of liquid water on Mars
  4. #wczg
 @slobodan_ • Only 18 missions to Mars
 have been

    successful • Temperature can also be -153°C • Mars has the largest dust storms
 in the solar system • Radiation • It doesn’t have an atmosphere
  5. #wczg
 @slobodan_ No, not that one, imagine the one that

    somebody would use :) AND NOW, IMAGINE YOU HAVE A WEBSITE
  6. #wczg
 @slobodan_ Chrome v123 on Illudium Q-36 Space Modulator 15:42

    Hm, what browser and network are you using? 15:18 Your **** website doesn’t work! 15:17 WTF?! 15:42
  7. #wczg
 @slobodan_ Your servers seems to be ok. It should

    just work, right? WHAT’S THE PROBLEM?
  8. #wczg
 @slobodan_ You tried, but they are still building their

    data center there… LATENCY?
 AH, CAN YOU JUST DEPLOY IT ON AWS ON MARS?
  9. #wczg
 @slobodan_ Beside crying and answering support emails, of course

    WHAT CAN WE DO WHEN WE DON’T HAVE ENOUGH SERVERS?
  10. #wczg
 @slobodan_ A computer network architecture that addresses lack of

    continuous connectivity DELAY/DISRUPTION TOLERANT NETWORKING
  11. #wczg
 @slobodan_ Networks are hard and boring, at least for

    me, let’s focus on things we know LET’S GO BACK TO THE WEB DEVELOPMENT
  12. #wczg
 @slobodan_ Our website would work even when the server

    is not available OFFLINE ACCESS WITH SERVICE WORKERS
  13. #wczg
 @slobodan_ Service workers essentially act as proxy servers that

    sit between web applications, and the browser and network (when available).
  14. #wczg
 @slobodan_ • Enable effective offline experiences • Intercept network

    requests and taking appropriate action based on whether the network is available • Allow access to push notifications • Background sync APIs.
  15. #wczg
 @slobodan_ We do not want to send too much

    API calls, because they are not cheap LESS API CALLS?
 GRAPHQL
  16. #wczg
 @slobodan_ A GraphQL query is a string interpreted by

    a server that returns data in a specified format.
  17. #wczg
 @slobodan_ Storage would be useful, then we don’t depend

    on the server all the time STORE THINGS LOCALLY WITH INDEXEDDB
  18. #wczg
 @slobodan_ IndexedDB is a low-level API for client-side storage

    of significant amounts of structured data, including files/blobs. This API uses indexes to enable high performance searches of this data.
  19. #wczg
 @slobodan_ • Key-value pairs • Built on a transactional

    database model • Mostly asynchronous • It uses DOM events to notify you when results are available • noSQL • Same-origin policy
  20. #wczg
 @slobodan_ Sync our local database when ever server is

    available DATA SYNCHRONIZATION? POUCHDB
  21. #wczg
 @slobodan_ PouchDB is an open-source JavaScript database inspired by

    Apache CouchDB that is designed to run well within the browser.
  22. #wczg
 @slobodan_ It enables applications to store data locally while

    offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.
  23. #wczg
 @slobodan_ Background sync is a new web API that

    lets you defer actions until the user has stable connectivity.
 
 This is useful for ensuring that whatever the user wants to send, is actually sent.
  24. #wczg
 @slobodan_ SW caching can fail if you close the

    browser while caching big assets! More info:
 https://github.com/jakearchibald/background-cache
  25. #wczg
 @slobodan_ • Enable background-caching of multiple resources • Enable

    background-uploading of multiple resources • Allow the OS to handle the fetch, so the browser doesn't need to run More info:
 https://github.com/jakearchibald/background-cache
  26. #wczg
 @slobodan_ • Allow the OS to show UI to

    indicate the progress of the fetch • Allow the OS to deal with poor connectivity by pausing/resuming the download/upload • Allow the app to react to /failure of the fetch More info:
 https://github.com/jakearchibald/background-cache
  27. #wczg
 @slobodan_ Don’t use the server when ever you don’t

    really need to PEER-TO-PEER CONNECTION WITH WEBRTC
  28. #wczg
 @slobodan_ WebRTC is a free, open project that provides

    browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs
  29. #wczg
 @slobodan_ WebTorrent is written completely in JavaScript – the

    language of the web – and uses WebRTC for peer-to-peer transport whenever possible.
 
 No browser plugins, extensions, or installation is required to use WebTorrent in your browser.
  30. #wczg
 @slobodan_ “Imagine a peer-to-peer YouTube where viewers help to

    host the site's content. By making BitTorrent easier to use, we can get more people to participate and take the first steps to re-decentralizing the Internet.”
  31. #wczg
 @slobodan_ A file sharing network based on rabin file

    chunking and append only feeds of data verified by merkle trees. More info:
 https://github.com/datproject/docs/blob/master/docs/hyperdrive_spec.md
  32. #wczg
 @slobodan_ Hyperdrive is the peer-to-peer data distribution protocol that

    powers Dat. It consists of two parts. More info:
 https://github.com/datproject/docs/blob/master/docs/hyperdrive_spec.md
  33. #wczg
 @slobodan_ First there is hypercore which is the core

    protocol and swarm that handles distributing append-only logs of any binary data. More info:
 https://github.com/datproject/docs/blob/master/docs/hyperdrive_spec.md
  34. #wczg
 @slobodan_ The second part is hyperdrive which adds a

    filesystem specific protocol on top of hypercore. More info:
 https://github.com/datproject/docs/blob/master/docs/hyperdrive_spec.md
  35. #wczg
 @slobodan_ This solves just a small part of the

    problems WHAT OTHER PROBLEMS WE NEED TO SOLVE?
  36. #wczg
 @slobodan_ • Timestamps • Storing and checking session •

    Security and privacy • How do we test the extreme situations?
  37. #wczg
 @slobodan_ WE NOW KNOW
 HOW TO BUILD
 AN INSTAGRAM

    FOR MARS? We need a place to share food images, right?
  38. #wczg
 @slobodan_ MOST OF THE THINGS WE ARE BUILDING ARE

    NOT EVEN WORKING FOR EVERYONE ON THIS PLANET