This document discusses building a mini game challenge for a soccer app using Python, AsyncIO, WebSockets, and Redis. It introduces the speaker as the organizer of KhmelnitskiyPy and CTO of Turfmapp, a soccer-focused meetup app. It then explains how AsyncIO allows asynchronous programming in Python without additional libraries. WebSockets enable real-time communication between server and clients. Redis is used as a high performance cache and store for publishing game state updates to clients over WebSockets.
Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React
1. Send Balls Into Orbit with
Python3, AsyncIO,
WebSockets, Redis and React
Taras Lyapun, KhmelnitskiyPy#1
2. About me
- Organizer of KhmelnytskyiPy
- CTO at Turfmapp.com
- Founder of Four-Eyes.IO
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. What is this story
about?
- We had everything for players
before game
- But we didn’t have anything for
game
- Introduce - Mini Challenges
5. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
6. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
7. Python
• Simple
• Maintainable
• Powerful
• Great syntax
• Can be used for anything:
• web
• network
• math
• ML
• NLP
• etc
• Great community!
8. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
9. Python3
• New, modern version of
Language
• A lot of improvements
• Unicode everywhere
• Lazy by default
• One more thing…
10. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
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
15. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
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
18. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React
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
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. Send Balls Into Orbit with Python3, AsyncIO,
WebSockets, Redis and React