O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React

720 visualizações

Publicada em

Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React

KhmelnitskyiPy #1
Хмельницкий, Украина
25 июля 2015

Publicada em: Software
  • Seja o primeiro a comentar

Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React

  1. 1. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React Taras Lyapun, KhmelnitskiyPy#1
  2. 2. About me - Organizer of KhmelnytskyiPy - CTO at Turfmapp.com - Founder of Four-Eyes.IO
  3. 3. Turfmapp.com • Find places and company to play soccer • Like meetup.com, but soccer specific • Like runkeeper.com, but for team sports • Chicago based startup, with R&D office in Khmelnitskiy
  4. 4. What is this story about? - We had everything for players before game - But we didn’t have anything for game - Introduce - Mini Challenges
  5. 5. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  6. 6. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  7. 7. Python • Simple • Maintainable • Powerful • Great syntax • Can be used for anything: • web • network • math • ML • NLP • etc • Great community!
  8. 8. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  9. 9. Python3 • New, modern version of Language • A lot of improvements • Unicode everywhere • Lazy by default • One more thing…
  10. 10. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  11. 11. AsyncIO • Allows you to start event loop, and execute your code asynchronously without additional libraries or frameworks • So you can write your python code in both ways - sync and async, depends on your task • Allows you easy support thousands persistent connections without threads overhead • The best way to deal with network
  12. 12. Introduction to Asynchronous Programming http://cs.brown.edu/courses/cs168/f12/handouts/async.pdf
  13. 13. PEP-0492
  14. 14. PEP-0492
  15. 15. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  16. 16. WebSockets • Full-duplex communication channel over TCP • Allow you to have real-time communication between server and client • Supported by most browsers, but can be used also with any client (ios, android, whatever) • aiohttp handles it well
  17. 17. aiohttp
  18. 18. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  19. 19. Redis • Advanced Key-Value cache and store • Strings, hashes, lists, sets, etc • Publish Subscribe • High performance with good enough level of persistency for this task
  20. 20. asyncio-redis
  21. 21. Another Decisions • Always send full state of game (everything needed to display screen), instead of sending incremental updates - easy and error prone • How to deal with concurrency updates? - Some sort of optimistic locks • Use JSON for easy extending protocol • Process all data through Redis - for easy scale
  22. 22. Send Balls Into Orbit with Python3, AsyncIO, WebSockets, Redis and React
  23. 23. Thanks!

×