Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building MapAttack


Published on

Discussion about making games on Geoloqi, demoing MapAttack

Published in: Technology
  • Be the first to comment

Building MapAttack

  1. 1. Building MapAttack: Areal-time geolocation game Kyle Drake
  2. 2. What is Geoloqi?
  3. 3. Real-world solutionsfor thousands around the globe
  4. 4. Real-Time Location TrackingReal-World Interactive Experiences
  5. 5. geoloqi.comPersonal Location
  6. 6. geoloqi.comLocation-Based Notes
  8. 8. geoloqi.comReal-Time Applications
  9. 9.
  10. 10. geoloqi.comFirst Hackathon Attempt Layer in Geoloqi Updates to MapAttack servervia HTTP REST API Processing through Geoloqi’spersistent store Finished in a weekend A lot of fun!
  11. 11. geoloqi.comThere were some kinks Used an REST HTTP service forAPNS (worked, but not “real-time”) Server was getting backed up(updates were not async)
  12. 12. MapAttack Server Issues Blocking IO (requests to Geoloqi API heldeverything up) Lots of concurrent traffic Events had to be broadcast to all phones/clients in the game synchronously
  14. 14.
  15. 15. geoloqi.comA key-value store, and so much moreA great implementation of PUBLISH/SUBSCRIBESo simple, you can actually understand itVery fast and reliableRobust library support
  16. 16.
  17. 17.
  18. 18.
  19. 19. HOW WE USE NODE JS• Phones:Custom binary protocol over UDP• Web Browsers:Web Sockets via Socket.IO
  20. 20. geoloqi.comSocket.IO is awesome Adapter Pattern for realtime Web Sockets, Flash, Long Polling! One interface for everything Easy to implement: ~100 LOC
  21. 21.
  22. 22. Geoloqi APIASYNC FTW!Delayed updates when possibleMessages queues: BeanstalkWorkers pick tasks off the stackProcess data outside of the persistent storeSimpler than AMQP
  23. 23.
  24. 24. MapAttack Server (or: How to make Ruby ROFLscale)MRI Ruby has a global interpreter lockBut MRI Ruby does not block on IOJRuby and Rubinius 2: Native ThreadsAnd it has a reactor pattern, just like Node JS!
  25. 25. The Reactor Pattern “The reactor design pattern is a concurrent programming pattern for handling service requests delivered concurrently to a service handler by one or more inputs” - Wikipedia My simplest description: Takes your blocking IO operation, shoves it into its own kernel threadbehind the scenes, uses Unix kernel magic to make it rejoin the reactor queue when it’s ready. Linux: epoll(4) BSD: kqueue/kevent
  26. 26. geoloqi.comBlocking IO a UNIVERSAL problemAll programming languages have trouble with itThe Reactor pattern is a tool to resolve itMost languages have the Reactor pattern!JavaScript Node.js Python Twisted Ruby EventMachine (libem, C) Java JBoss_Netty (wait, what? I thought Java had good threading..) PHP None yet (perhaps ever)
  27. 27. geoloqi.comSinatra::Synchrony EventMachine with FibersThe result: NO CALLBACKS!< 100 LOCOnly coding change is to use EM libs and fibersWOW, THAT WAS EASY.
  28. 28. geoloqi.comSinatra::Synchrony
  29. 29.
  30. 30. geoloqi.comLet’s Talk Performance.
  31. 31. geoloqi.comMake the relevant datastay outside of the slow persistence store.
  32. 32. geoloqi.comIf you’re trying to solve a problem by ROFLscaling your persistent store, you’re doing it wrong.
  33. 33. Examples of doing it wrong “Let’s rewrite everything to use TrendDB” Using EC2 for a single-master DB “because it scales” Buying something from Oracle “Ruby/PHP/JS is too slow for this, let’s rewrite it inTrendLang” Most NoSQL solutions have dark secrets you don’tknow about. Global write locks, single write master, etcetera
  34. 34. geoloqi.comIf you must speed up your persistent store, here’s my practical advice.
  35. 35. Real Hardware FTW? Single master database? Get a real server! Really! Cloud is only as fast as the fastest available HDD EBS performance is not great, even in RAID0 stripeSee High end Xeon, 32GB ECC, fast 220GB SSD: ~$2K
  36. 36. Real Hardware FTW?The paradigm is diversifying, and the reason is SSD.Say hello to the Fusion-io ioDrive Octal.PCIe x16 slot5.12TB6.0 GB/s read4.4 GB/s write1.19 MILLION IOPSCost: $100,000 (plus $10 S&H).It’s a steal at this price.. but it will get cheaper.
  37. 37. geoloqi.comReal Hardware FTW? $500 PCIe SSD drives: 220GB >100,000 IOPS ~700MB/s R/W 15,000 RPM SAS drives: 2TB+ ~175-210 IOPS <150MB/s R/W
  38. 38. Long Term Multi-master experiment (Brewer’s CAP) Riak is my current favorite Cloud companies providing real hardwareperformance
  39. 39. geoloqi.comIn Summary
  40. 40. geoloqi.comGeo-location games are FUN!
  41. 41. Use the Geoloqi API to makegeolocation games! We did the hard work for you.
  42. 42. geoloqi.comMapAttack is open source!
  43. 43. Text
  44. 44. geoloqi.comOther uses of Geoloqi
  45. 45. geoloqi.comThanks!