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

Stateful Apps with OTP

Stateful Apps with OTP

373dd7c51433dc3c38436dcfdec79cdc?s=128

Maciej Kaszubowski

April 20, 2017
Tweet

Transcript

  1. Stateful Apps with OTP Maciej Kaszubowski

  2. Realtime Apps with OTP Maciej Kaszubowski

  3. Background

  4. Http Server Client

  5. Architecture Server Mobile Mobile Kurento Mobile Websocket Websocket & REST

    WebRTC
  6. Challenges

  7. Async communication with Kurento

  8. Async communication with Clients

  9. Handling Concurrent Calls

  10. Deploys, migrations & Restarts

  11. A lot can go wrong

  12. A lot can go wrong & Errors are dangerous

  13. How to deal with this?

  14. init callback

  15. init callback

  16. init callback

  17. init callback

  18. init callback

  19. init callback

  20. Dealing with failures

  21. RoomServer

  22. RoomServer

  23. Let it FAIL

  24. Room Supervisor RoomServer

  25. Room Supervisor RoomServer

  26. Room Supervisor RoomServer

  27. After the restart, the state is gone

  28. Room Supervisor BackupServer RoomServer

  29. None
  30. Room Supervisor BackupServer RoomServer

  31. None
  32. None
  33. Multiple calls

  34. Room Supervisor BackupServer RoomServer

  35. Common Room Supervisor Room Supervisor Backup Server Room Server Room

    Supervisor Backup Server Room Server
  36. Common Room Supervisor Room Supervisor Backup Server Room Server Room

    Supervisor Backup Server Room Server
  37. Common Room Supervisor Room Supervisor Backup Server Room Server Room

    Supervisor Backup Server Room Server
  38. Common Room Supervisor Room Supervisor Backup Server Room Server

  39. PubSub

  40. Status Updates Server Mobile Join Mobile Room status

  41. MyApp.Endpoint.broadcast( “room_id”, “update_status”, status )

  42. apps/ | |—— domain/ |—— web/

  43. Status Updates Server Mobile Mobile Subscribe Subscribe

  44. Status Updates Server Mobile Mobile Join

  45. Status Updates Server Mobile Mobile Status update Status update

  46. Status Updates

  47. Status Updates

  48. Status Updates

  49. Status Updates

  50. Status Updates

  51. Status Updates

  52. History

  53. History Server Call History Subscribe Status update

  54. History

  55. History

  56. History

  57. Conclusions

  58. Simpler system

  59. Testing is easy

  60. Changes are easy

  61. Great performance

  62. We should learn from the Erlang community

  63. A lot of fun!

  64. Thanks!