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.
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Abstract
●
“How we build a W.I.F.E.* system using Python”
– *Wirel...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Hi!
●
I'm David Arcos
●
Python/Django developer since 2008
●
Co-or...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Immfly
Private & Confidential
Immfly is a new Entertainment, Retai...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
1) The product requirements
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
How does it work?
The passenger's device
(smartphone/tablet/laptop...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
What kind of services?
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
What kind of services?
●
Flight information
●
View TV Shows, video...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
But it's off-line
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
We need eventual connectivity
●
Update the contents
“I don't want ...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Ground mode
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Ground mode
●
Keep the experience after landing
●
Bring your conte...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
2) The Architecture
●
In the airplane:
– Frontend & Backend
– Syst...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Frontend apps
●
Web app:
●
Mobile apps:
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Backend API
●
“A powerful and
flexible toolkit
that makes it easy
...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
HTTP server
●
Monitor and
control:
– API
– daemons
– celery
●
WSGI...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Databases
●
NoSQL data
– Cache, sessions
– Metrics, expirations
●
...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Network
Fabric
– Initializing
– Other tasks
Ansible
– Deployment
–...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Hardware
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Wireless Access Points
●
3 WAPs per plane
●
Provide the WiFi
●
Iso...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Aircraft Server
●
Embedded computer
– Hardened, certifed
●
Xen wit...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Avionics data bus
● altitude
● flight_id
● ground_speed
● heading
...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Discrete-time signals
● DCFAILSIG
● ACFAILSIG
● OVERTEMPSIG
● GSM_...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
The Hangar
●
Hosted in the Internet
●
Central point
●
Orchestrates...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Hangar Operations
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Resource ingest
●
Thousands of resources, from ~20 providers
– Per...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Ingesting videos
●
Ingest from SFTP / AWS S3
●
Send to AWS Elastic...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Ingesting reading
●
Ingest from SFTP / AWS S3
●
Celery task:
– Red...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Ground mode
●
Similar to the “Aircraft” mode
●
Minor differences:
...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
3) Atypical challenges
●
Specifc perks of working with aircrafts
●...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Regulations & Certifications
End of 2013, EASA allowed use of PEDs
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Certificate everything!
●
Had to certifcate every step
– The hardw...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Certificate everything!
●
Had to certifcate every step
– The hardw...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Intermittent connectivity
●
We get 30~90m of connectivity per day
...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Hard shutdown
●
Electrical power is suddenly removed, and our
airp...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Mistake: trusted the hardware
●
File system corruption
– The HDD w...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
The CAP Theorem
“It's impossible for a distributed system to
simul...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Big mistake: try to beat the CAP
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Settled for “Eventual Consistency”
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Recap
●
Complex project with lots of features
– Kept a modular des...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Conclusions
●
Python made it possible!
●
Very versatile, covers al...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Thanks for attending!
- Get the slides at http://slideshare.net/DZ...
Python in the Sky – EuroPython 2015 David Arcos - @DZPM
Questions?
Upcoming SlideShare
Loading in …5
×

Python in the Sky

4,169 views

Published on

Case study of an In-Flight Entertainment system, built using Python.

This talk will show the basic requirements for the system and the architecture decisions we took.

Besides, running software at 10.000 meters implies new unexpected challenges, different from the ones we encounter day-to-day. We’ll focus on how we solved them.

https://ep2015.europython.eu/conference/talks/python-in-the-sky-in-flight-entertainment-with-python

Published in: Technology
  • Had my first experience with Immfly a few days ago while flying PMI-LHR with Iberia Express. And naturally, being a techy, I tried to figure out how the system worked, so your slidedeck is really illuminating! Many thanks for sharing. FYI, I thought it might be based on Couchbase Mobile / Sync Gateway.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Python in the Sky

  1. 1. Python in the Sky – EuroPython 2015 David Arcos - @DZPM
  2. 2. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Abstract ● “How we build a W.I.F.E.* system using Python” – *Wireless In-Flight Entertainment ● Main topics: – 1) Product requirements – 2) Architecture decisions – 3) Atypical challenges
  3. 3. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Hi! ● I'm David Arcos ● Python/Django developer since 2008 ● Co-organizer of Python Barcelona ● Lead engineer at Immfly
  4. 4. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Immfly Private & Confidential Immfly is a new Entertainment, Retail and Communication platform for the in-flight experience. Focused on the European domestic flights market, Immfly offers wireless content to passengers via their Personal Electronic Devices.
  5. 5. Python in the Sky – EuroPython 2015 David Arcos - @DZPM 1) The product requirements
  6. 6. Python in the Sky – EuroPython 2015 David Arcos - @DZPM How does it work? The passenger's device (smartphone/tablet/laptop) connects to the wif (no internet!) and opens the app (web/android/ios)
  7. 7. Python in the Sky – EuroPython 2015 David Arcos - @DZPM What kind of services?
  8. 8. Python in the Sky – EuroPython 2015 David Arcos - @DZPM What kind of services? ● Flight information ● View TV Shows, videos ● Read newspapers, magazines ● Get guides, offers, deals ● Etc...
  9. 9. Python in the Sky – EuroPython 2015 David Arcos - @DZPM But it's off-line
  10. 10. Python in the Sky – EuroPython 2015 David Arcos - @DZPM We need eventual connectivity ● Update the contents “I don't want yesterday's newspaper!” ● Send “booking” actions to external APIs ● Do payments ● Send emails
  11. 11. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Ground mode
  12. 12. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Ground mode ● Keep the experience after landing ● Bring your contents with you ● Get email confrmations
  13. 13. Python in the Sky – EuroPython 2015 David Arcos - @DZPM 2) The Architecture ● In the airplane: – Frontend & Backend – System services – Hardware ● In the datacenter: – The "Hangar" – Ingests
  14. 14. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Frontend apps ● Web app: ● Mobile apps:
  15. 15. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Backend API ● “A powerful and flexible toolkit that makes it easy to build Web APIs” ● “The web framework for perfectionists with deadlines” ● “A widely used general-purpose, high-level programming language”
  16. 16. Python in the Sky – EuroPython 2015 David Arcos - @DZPM HTTP server ● Monitor and control: – API – daemons – celery ● WSGI Server● Web Server ● Static contents
  17. 17. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Databases ● NoSQL data – Cache, sessions – Metrics, expirations ● SQL data – Django ORM – Critical transactions
  18. 18. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Network Fabric – Initializing – Other tasks Ansible – Deployment – Confg Management – Pull mode SSH – Through VPN – Hidden port – PK Auth
  19. 19. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Hardware
  20. 20. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Wireless Access Points ● 3 WAPs per plane ● Provide the WiFi ● Isolated users
  21. 21. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Aircraft Server ● Embedded computer – Hardened, certifed ● Xen with Ubuntu VMs ● Internal 3G data card ● Avionics bus
  22. 22. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Avionics data bus ● altitude ● flight_id ● ground_speed ● heading ● latitude ● longitude ● mach_speed ● outside_temperature ● pitch ● roll ● wind_speed ● yaw We have access to this data, in real-time:
  23. 23. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Discrete-time signals ● DCFAILSIG ● ACFAILSIG ● OVERTEMPSIG ● GSM_POWER_STATUS ● ENB2SIG ● ENB1SIG ● ENB0SIG ● GSMSIG_STATUS ● CPLD_REV0 ● CPLD_REV1 ● SYSENSIG ● ENB3SIG ● ENB4SIG ● ENB5SIG ● ALERT ● CONFIGSIG0 ● CONFIGSIG1 ● CONFIGSIG2 ● INTTEST_OUT ● INTTEST_IN ● ISO_OUT0 ● ISO_OUT1 ● ISO_OUT2 ● ISO_OUT3 ● GPIO_DCFAILSIG ● GPIO_ACFAILSIG ● GPIO_OVERTEMPSIG ● GPIO_SYSENSIG
  24. 24. Python in the Sky – EuroPython 2015 David Arcos - @DZPM The Hangar ● Hosted in the Internet ● Central point ● Orchestrates the operations ● Update contents, databases, code...
  25. 25. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Hangar Operations
  26. 26. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Resource ingest ● Thousands of resources, from ~20 providers – Per language – Per country – Per category: Videos, Readings, Deals... ● Some external APIs are questionable: – Missing SSL, Documentation... – Manually updates to an ftp... – Data in excel fles...
  27. 27. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Ingesting videos ● Ingest from SFTP / AWS S3 ● Send to AWS ElasticTranscoder – Convert to HLS ● Sync chunk by chunk
  28. 28. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Ingesting reading ● Ingest from SFTP / AWS S3 ● Celery task: – Reduce size (image resolution) – Generate thumbnails
  29. 29. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Ground mode ● Similar to the “Aircraft” mode ● Minor differences: – No Videos (we don't have the permissions) – More focus on destination offers – Online functionality (like “forgot my password”) ● Made to scale
  30. 30. Python in the Sky – EuroPython 2015 David Arcos - @DZPM 3) Atypical challenges ● Specifc perks of working with aircrafts ● Dealing with airplanes has extra challenges ● Problems we weren't expecting beforehand ● Also, “mistakes where made”
  31. 31. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Regulations & Certifications End of 2013, EASA allowed use of PEDs
  32. 32. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Certificate everything! ● Had to certifcate every step – The hardware was already certifed – The WAPs were already certifed – Lots of wireless tests ● Even the smallest screw has to be certifed! ● Took us 6-9 months!
  33. 33. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Certificate everything! ● Had to certifcate every step – The hardware was already certifed – The WAPs were already certifed – Lots of wireless tests ● Even the smallest screw has to be certifed! ● Took us 6-9 months!
  34. 34. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Intermittent connectivity ● We get 30~90m of connectivity per day – 10-15 minutes after each flight ● Sometimes, roaming applies – Limited synchro ● Improve the deployment tools ● Optimize the performance
  35. 35. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Hard shutdown ● Electrical power is suddenly removed, and our airplane server is turned off ● Happens often: – When changing power from engine to external, after landing – If there is a storm, or just if the pilot wishes ● We could only mitigate...
  36. 36. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Mistake: trusted the hardware ● File system corruption – The HDD write buffer is sometimes lost – Corrupted fles – fsck at start – sync after each deploy – Added several consistency checks (for contents) ● Internal clock corruption – Logs showed wrong times – Added NTP checks (requires connectivity)
  37. 37. Python in the Sky – EuroPython 2015 David Arcos - @DZPM The CAP Theorem “It's impossible for a distributed system to simultaneously provide all three:” - Consistency All nodes see the same data at the same time - Availability Guarantee that every request receives a response - Partition tolerance Continue to operate despite network partitioning
  38. 38. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Big mistake: try to beat the CAP
  39. 39. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Settled for “Eventual Consistency”
  40. 40. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Recap ● Complex project with lots of features – Kept a modular design ● Could implement everything – helped by existing Python libraries ● Learned a lot from unexpected challenges
  41. 41. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Conclusions ● Python made it possible! ● Very versatile, covers all our use cases ● “We stand on the shoulders of giants” ● Developed in a short time
  42. 42. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Thanks for attending! - Get the slides at http://slideshare.net/DZPM - We're hiring! http://immfly.com/jobs
  43. 43. Python in the Sky – EuroPython 2015 David Arcos - @DZPM Questions?

×