Butter smooth, interactive applications with Django and Websockets

Video in TIB AV-Portal: Butter smooth, interactive applications with Django and Websockets

Formal Metadata

Butter smooth, interactive applications with Django and Websockets
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Web applications have changed significantly over the years – from simple static pages, to sprinkling interactiveness with JQuery/AJAX, to full dynamic single page apps. Through each evolution, we’re adding more complexity, more data and more asynchronous behavior to our applications. In this new world, where does the synchronous nature of Django’s request-response cycle fit in? My talk will focus on the topics around asynchronous Django applications. I’ll be sharing some lessons we learnt while building and scaling an interactive web application within the confines of Django and django-channels. This topic is interesting because there’s been a lot of interest with meteor-like frameworks that have synchronized state between the frontend and backend. My intention is to show the audience that you can accomplish the same end-result with Django, without the need to learn and deploy a brand new framework. An outline I have in mind: What does asynchrony mean, and why you need it. Traditional methods of achieving asynchrony (delayed jobs using worker queues like celery, long-polling for messaging, etc.) Why django-channels changes the game. How to architect your state. What are the available options for deployment. Gotchas, and what to do when things go wrong. Just a basic knowledge of Django is required, as the topics are transferable to other frameworks. We did not have to monkey-patch any of the drivers to achieve asynchrony, so what you’ll learn at my talk will apply cleanly to a stock Django.
Socket-Schnittstelle Electronic data interchange Smoothing Gender Interactive television Interactive television Cartesian coordinate system System call Web application Maize Computer animation Logic Internetworking Smoothing Arithmetic progression
Assembly language Sequel Multiplication sign Data analysis Maxima and minima Data analysis Black box Computer programming Product (business) Number Wiki Type theory Computer animation Blog Query language Energy level Cuboid Writing
Web page Histogram Group action Sequel Computer file Data analysis Computer font Subset Web 2.0 Cross-correlation Fluid Googol Software framework Booting Linear map Histogram Email Dependent and independent variables Metre Outlier Linear regression Forcing (mathematics) Debugger Electronic mailing list Interactive television Correlation and dependence Database Line (geometry) Cartesian coordinate system Frame problem Web application Benutzerhandbuch Googol Algebra Computer animation Query language Musical ensemble Family
Web page Point (geometry) Trail Service (economics) Open source Sequel View (database) Water vapor Web browser Regular graph Product (business) Web 2.0 Fluid Single-precision floating-point format Network socket Visualization (computer graphics) Query language Cuboid Software framework Physical system Data type Mapping Interactive television Cartesian coordinate system Web application Film editing Event horizon Computer animation Personal digital assistant Hybrid computer Right angle Text editor Spectrum (functional analysis)
Laptop Point (geometry) Web page Mobile app Socket-Schnittstelle Server (computing) Thread (computing) Sequel Dependent and independent variables Code State of matter Multiplication sign Web browser Product (business) 2 (number) Number Mathematics Synchronization Different (Kate Ryan album) Single-precision floating-point format Office suite Endliche Modelltheorie Exception handling Dependent and independent variables Matching (graph theory) Run time (program lifecycle phase) Structural load Projective plane Debugger Analytic set Fehlererkennung Lastprofil Type theory Message passing Computer animation Query language Network socket Video game Iteration Right angle Cycle (graph theory) Resultant
Laptop Point (geometry) Presentation of a group Building Server (computing) State of matter Multiplication sign Connectivity (graph theory) Device driver Client (computing) Correlation and dependence Event horizon Proper map Product (business) Front and back ends Goodness of fit Computer configuration Network socket Core dump Compiler Cuboid Software framework Position operator Computer architecture Mapping Server (computing) Gender Debugger Projective plane State of matter Electronic mailing list Stack (abstract data type) Device driver Front and back ends Connected space Component-based software engineering Proof theory Computer animation Personal digital assistant Query language Lastteilung Gastropod shell Arithmetic progression
Laptop Email Greatest element Structural load Code Connectivity (graph theory) Client (computing) Computer programming Wave packet Product (business) Revision control Architecture Energy level Diagram Message passing HTTP cookie Computer architecture Point cloud Authentication Server (computing) Weight Projective plane Planning Database Cartesian coordinate system Front and back ends Dynamic Host Configuration Protocol Maize Computer animation Network socket Hybrid computer Point cloud Lastteilung HTTP cookie Whiteboard Diagram Asynchronous Transfer Mode
Point (geometry) Trail Multiplication sign Client (computing) Cursor (computers) Shape (magazine) Client (computing) Cursor (computers) Connected space Message passing Sign (mathematics) Computer animation Point cloud Website Message passing Physical system
Implementation Consistency Data storage device Set (mathematics) Database Client (computing) Sequence Timestamp Message passing Computer animation Ring (mathematics) Logic Buffer solution Set (mathematics) Energy level Data structure Quicksort Table (information) Message passing
Email State of matter Debugger View (database) Multiplication sign Client (computing) Front and back ends Blog Different (Kate Ryan album) Bus (computing) Cuboid Diagram HTTP cookie Physical system Point cloud Boss Corporation Computer font Electronic mailing list Data storage device Streaming media Front and back ends Web application Message passing Touch typing Order (biology) output Whiteboard Middleware Server (computing) Mobile app Sequel Connectivity (graph theory) Cursor (computers) Streaming media Drop (liquid) Number Element (mathematics) Architecture Cross-site scripting Term (mathematics) Software testing Message passing Computer architecture Server (computing) Debugger Client (computing) Frame problem Graphical user interface Event horizon Hypermedia Computer animation Query language Network socket Abstraction
Building Greatest element Code Plotter View (database) Sheaf (mathematics) Numbering scheme Insertion loss Client (computing) Data analysis Correlation and dependence Mereology IP address Web 2.0 Fluid statics Bit rate Different (Kate Ryan album) Network socket Bus (computing) Endliche Modelltheorie Office suite Email Structural load Instance (computer science) Flow separation Type theory Data model Message passing Curvature Data management Right angle Lastteilung Quicksort Cycle (graph theory) Pole (complex analysis) Point (geometry) Server (computing) Sequel Computer file Virtual machine Raw image format Event horizon 2 (number) Revision control Internetworking Energy level Condition number Computer architecture Authentication Dependent and independent variables Debugger Database Line (geometry) Affine space System call Human migration Personal digital assistant Query language Network socket Formal grammar Video game HTTP cookie
and the and the and and I
IV the room thank what I need and that's very good also excited to be here general corn out my 1st gender corner and besides the people were always by the communities k plus the food was exceptional ability to a logic as a so in the from call after lunch but let's say z so the title of my talk is about a smooth interactive applications with Django and that sockets and so I'm going to be giving a little preview of are interactiveness on the internet with regards to web applications and then build up to its Django channels and WebSockets and now the the kinds of problems that we faced I'm not gonna go too much detail into how rare a channels work because it's a work in progress and their of believe there a full tutorial on general channels and now a lot of the other talks the talk would GeneChip channels specifically so i'm going be talking about the tooling and us and the deployment the issues that we had a
more formal introduction about myself i've been not working with them Python data for over 10 years I I started my career writing assembly programming and and just look my way up to up the stack some like a full stack them but stop so that at some level so I've written programs for GP user a lower back and stuff but I really love Python I love jangle allow clean and now None of the magic number the black box stuff you can just open up the cold and see what's going on I have been doing data analysis and sequel for the past couple of years up my claim to fame is I wrote the 1st wiki engine for max and now wiki blog engine so that was pretty cool was accepted into mainland mainline Emacs and this is a long time ago are currently run solution which is a is a is a data analysis tool for professional data analysts and sickle recipes which our product is something like this
so this is just to give you a context and on on the challenges we faced are you type in sequel there it's a text box and you had run and it creates these charts and then you can now scheduled these charts show these charts and our do whatever you want so that's essentially our product as we use is the product
professional data analysts so if you're it's not sequel like the all warm start sequel it's for building histograms correlations are doing forecasting regressions all the kinds of data analysis stuff you would do but using sequel so the google for solo simple recipes others a full list of I think 2 dozen arrest copy-paste editing a straight up sequel so this is a timeline of the
asynchronous behavior on the red but I mean the days are familiar with I frames that's awesome so but 20 years ago I frames was how you be out you get interactive file that applications if you guys if only with MapQuest and some of the ideas the pre Web 1 . 0 kind of applications you click a button and it dynamically generates frame your else and it refreshes I believe in even hotmail the force was a partner work that way so you click sand it refreshes frame so that was like interactive of web apps and then now around 99 Mike self interviews XML HTTP request of which is a precursor to Ajax it's a way of creating asynchronous requests responses around 2004 Gmail launched and you know was the 1st I would say kind of a single page absolutes no full page refresh when you hit send to send an e-mail I around 2005 Ajax the dome Ajax was I've 2005 was and Django was released publicly and in 2012 reaches yes and if you as a family would need UGS for her Austin so judges like um was mind-blowing therefore so will have a look so it too is like an interactive fluid that framework where there is a subset of your database being held on the front and the query of front end and it's it's pretty fluid is pretty amazing how it all works I I still don't know if it's a good idea but that's it's pretty sweet yeah the 2014 react was public started getting adoption are I believe that's then the single-page AP acronym SBA was started getting into the mainstream 2016 I believe there's a small framework called rails but they now include WebSocket support into their line recall that act action cable so that's roughly the outline of interactive news on the web so this is a
very common way to visualize how technologies grow and get adopted and across a wide spectrum so I would say 2004 a lot of innovative adds 1 of risky applications were being built up probably only 10 or 15 % in the browser's out the support of the technologies with those that's the innovative far innovation and in track and is being used in 2004 to 2014 only majority big teams water resources very expensive to build these interactive that maps but it was being done in our case in a case in point Gmail Our goal maps follow the fullest was you know that bad streaming services and so on 2014 and up to now I believe era inching to was the promised land is that 1 of the best practices have been established but there's still some challenges in the fringes but more or less we understand how to build a single page act out what are the concerns what are the difficulties are there at least 3 of 4 mature front and frameworks that that worked out of the box view GS is a popular 1 reaction is is another popular 1 how a lot of folks use so that's pretty awesome hours so I think we're getting there between 2014 around then there's been a lot of the commercial applications of these fluid but you push notification canister so socket I O pusher fire based nuclear these are all a hybrid of open source and uh and um back in is a so this kind of system do you have an interactive web apps it the so the main question is why do you need this like what's up what's the right because Django has been around for 10 + years and now it looks pretty sweet why would you want to change something that's that's working perfectly fine so instead of answering this broad question about why I'm going to be a scoping it into our web app and why we saw the need for WebSockets interactiveness and why I just regular web absent in cut it and
yeah it so as a mention our product is that is a sequel editor essentially you have a text box you had run and then it creates these charts and then you go to this voxel over and over and over again so that's basically what product does so if you were to draw a schematic on how this works you
have the app which is the better running the browser there's an AJAX request that reaches the back in and then the back and which is jangle executes the sequel query and then returns the HTTP response so that's basically that the life cycle of Europe once 1 single iteration if there's a mistake in the sequel your executes equal to is an exception and it's sent back as a spear responses right our error codes and your friend and handles that it so this this work for in ways in 1 . 0 when we had no users and they were great so it is always pretty fun to see you had run in any it books and OK so awesome so let's go to production but the minute they had production once we got a couple of users we started seeing these problems there were creeping up so is going to enumerate so the problems you had is regular but request response cycle the 1st problem is unbounded at 1 time I for the request here
essentially what's happening is we let the user type an arbitrary sequel so we do not know beforehand how long the sequel is going to take it could take you know 3 minutes it could take 30 minutes because they have a big nobody knows because it's up to the user what what can a model or what kind of analytics there right so the problem was some of our users were diving this sequel paying run and imposing their laptop because a new it's going take half a day to run the query and from our side you know having the connection that across response going back and restoring the state was being that was a big challenge so that's the 1st difficulty are the 2nd difficulty was out what is is what we call 8 AM traffic spikes so in our product you can organize the Siegel queries into a dashboard to even have half a dozen to a dozen different charts and create a dashboard end at 8 AM our users load abuse dashboards and you have 15 queries hitting are back in and all trying to run and so that the ratio between the peak load to the low point was about 7 X so you have to provisions 7 x the number of so and resources to handle the load so when I casually Dr. my not will friends and so yeah I was at the opposite AM is they all good thing you you make about 6 had the gym go Veronika breakfast and then you were looking at no actually no idea a page at 755 that the was a down in their rush to the office to fix that but I don't tell them as a guy hit the gym and you know do all that stuff the 3rd challenge was about deployment because the Django servers were actually executing these queries you couldn't really swapped out new ways into the code so if you have have let's say 5 servers that executing this sequel queries and they could take anywhere from 30 minutes to let's say 3 hours deployment was a problem because deployment would kill that executing query and the user would never see the results so in a we believe in active deployments quick deployment the minute you test change of they succeed they just push diffraction but we were not able to do that because our users queries were failing or were being dominated so that was a big challenge so that is you know a summary of the challenges you've had with the synchronous request response cycle so we had to look for an alternate solution so looking around you know and I think I met Andrew last year the year before and he was just starting at maybe this is like watching . 0 0 1 of Django channels and I was pretty excited about it think OK Jan Jan which shall seems like the Holy Grail right what can go wrong so let's say let's play with it and so high-level how jagged channel works is that you still have your synchronous request-response response cycle which is on the on the top half and then you have a persistent bi-directional connections based on sockets in the lower half and so you send a message to your back in through the Ajax request and in the back and sends the response to the HP response just as usual but at the same time you can send messages back and forth through the WebSocket so you sober can initiate a message without having a matching http request or Ajax requests so that's conceptually How WebSockets or Django channels work they don't replace anything it just an add-on to existing workflow and so the method we used was you continue to use of when our users had run it still makes a HEP request to your back in and then you back in which is Django offloads it to this work a q excuse a sequel and once that's done using WebSockets notified the front and that the results are ready so we're able to push it out of that the so the out just as a thought experiment the ultimate old school approach would be would have been I'm using a thread on the on the front end to pull your back in 4 results and now I give the results you get a response but then that's undue load right you can't set the polling interval based the great because you don't know she will hit the back and let's say every 30 seconds and that's gonna break off of the user queries only take 2 seconds to run so the long pulling approach had its own issues so pretty amazing just went to the documentation copy paste the example to draw code are 2 days and he had all looking at he's looking at it was what my laptop OK so amazing that's got drinks because this project is done and you know it like that of my bonus check our will not not really it that is about 6 weeks to make a
production ready as a going from our laptop to our cluster so is I took a lot of time so you can copy this examples from the gender channels of a the rest of my talk is going to go into the challenges we faced are taking it to production which I did I guess is the meat of my presentation so it it looks at a lab are on my laptop you know and NDP and it's a proof of concept the challenges seem to you know that it looked promising so this is when you sit down and write a business case for Academy architecture at because this is pretty expensive you're writing the core of a rewriting the core of how you doing work I so we came up with is a
list bullet points and I'll just walk through them so the the big overarching aim of this project was to make the back and the driver of work at the front end just because the user sees run this of an going to obey that command you're going to schedule it and welcome that query when you see the reason we see is as a good time so we're going to be the back is going to be the driver rather than the client are inhaler handling of state you know they are out the state could be a query is in progress the corre has failed the query has succeeded in the query is ready to be run and then they're disconnections in the middle because people can go to train people could shut down the laptop so you just have to you know map out all the possible states and try to understand what's going on just a clear picture the on the server side events there are lots of approaches for doing this but there's so we should be able to communicate new data to the front end without the front and asking for it I think is a very powerful concept I no propriety solutions not that I'm against proprietary solutions but I feel that when you're working with brand new technology it's a lot harder to debug proprietary technology solutions so that 1 of the difficulty I have had with that of socket IO is you have to run socket I on the back end i which is no Gs and I was pretty challenging to I debug what was going on because I camera Python back in and debugging Extel stack was the challenge keep investments in Python with Django stack but I guess what a lot of other people would have done is there just thrown in the church yes or a no GS stack and offload this asynchronous component and do no Gs and let no GS deal with because there are lots of frameworks and no that help you do this but we do not want to do that because it then you have an architectural position and you add a new layer to the stack I think you're your product becomes kind of a Frank insane product and it just this is too much to keeping ahead because now if you try to hire someone there you're asking them for like react for an experience you asking them for general experience you asking for a node years experience in the deployment options is too much so we wanted to keep Everything standard out of the box Python + GenGO off the shelf AWS components are stack is completely on Amazon Web Services so we do not want to um build something custom i which means no recompiling engine next to add our WebSocket support our because we wanted to use Amazon's load balance of example because it has a lot of benefits it gives you health checks gear has good logging good logging framework it does that the DOS attacks a lot of a lot of good features and you 1 is tied into that ecosystem so it makes sense a lot of sense for us to Our bring in our own infrastructure components
yeah the roughly this is added is our architecture diagrams so we have our clients on the bottom which could be the I just found is in some kind of stencil program the that the fall in the laptop and the desktop of the kinds of clients and it connects to a load balancer which has WebSocket support and these are of the load balancer then starts to load balance to a back in which could be the WebSockets plus the red LED unicorn so it's a it's a hybrid it with the synchronous and asynchronous and then registers the persistence layer where the channels are being are shared so if you go to the GenGO channels documentation this is 1 now approach that's recommended using registers a back into the and of course you still have your standard our general component you have a database you have or and all that stuff roughly this is the architecture so now
the challenges Our why did it take a 6 weeks you know a that's that's a lot you know that I go on vacation for 4 weeks to the project no not really because that really training to solutions and we found that something was wrong and it goes back to the drawing board and you try to swap by the stuff I think there is some conflict with our initial motivations in our business plan where we wanted to stick to just the Python stack so a it was a lot lot more effort to get it to work but they didn't know now I'm really happy with that how it's all working out and going forward it's going to be a breeze to maintain because there's no custom code anywhere so the 1st challenge was cloud deployment I'm going to go a step by step into the challenges we faced so I if you remember the architecture diagram we need a load balancer in front of gene the corn and the asynchronous that's over other problem with a lot of the standard off-the-shelf wraps up load balancers is that the HCV people balances but what WebSockets needs is a TCP load balancer so all the stuff if you're familiar with Django cookie based authentication cookies are at http layer concerns so if you have a TCP load balancer can we attach that cookies like you can read the cookies so if you try to have sticky sessions based on cookies solid going to work and that I was surprised to see this but look a lot of the load balancers out there on the cloud where all HCP load balancers so Google blood is over the Amazon but fortunately Amazon launched a brand new mode balance last summer Call the application load balancer which is a TCP level advances but the the problem with a lot of Amazon's products is is that the documentation is just straight are on all our our they say yeah we don't recommend you doing this but that is exactly what you need to do a so scanner fortunate that I was taking the train from Vancouver BC which is home for me down to Portland for Pike on and now 1 of the Elastic Beanstalk engineers is gone in the training so is that unlike tons of and asking like why the hell is is not working what's wrong with this documentation wrong what he had the weight of the same stuff which are all like in different layers of about so the lesson here is to make sure it's working with the application load balancer of the deployment of new laptop or a different from the deployment on the cloud and try to try to figure out how application will bounce it works with the rest of you stack the
2nd challenge we had was how to do it missed messages on disconnect so here's an example let's say Django periodically sends a sober send message to your front right so it's moving upwards and so the green bars is when your client is connected to the back and and for some reason is disconnected either be user go through a tunnel or there's some kind of disconnection notice and the over sends a message but this message has nowhere to go to the point is not connected so that's the stop sign or the no entry site and then the client reconnects and it's missed those messages and it happens again so if you're going to be missing a lot of the messages that you back and sends you and back and has no no kind of system to to acknowledge that these messages have been received you then left in a very bad shape use your client status is going to be an in it is it's pretty challenging and now I was surprised to find that on the cloud it's actually quite frequent the disconnect our persistent connections is just not not a guarantee so there is an Indian package called reconnecting WebSockets essential does the for loop in into the disconnected down tries to reconnect so that was easy but what we had to do is actually fixed that missed messages on the back and so or solution to that
was to serialize all of the messages being sent from the back in time stamp it and implement a cursor on the client side so at the back and sends message 1 message to message the message for the client keeps track of 1 2 and then receives for OK you know what is a problem so go back to 2 and give me all the messages to so that's roughly
how it's essentially a table but the store on the back in and in the client implements as logic where it there that there is a gap in the sequence you can go back and we find that courses so
what we did here as an implementation level detail is not distorted in our database but readers has a z a such a called sort sets and so you can actually pop and push into this red its structure and it's actually really fast so there's no there's no delay in in trying to store this this ring buffer so we also wrote a middle there because you want to make sure that every message going from the back and I was going to was being timestamp and sequential iced so was important to go to that single stream and at
the are the problem was our friend architecture or friend is a is a single-page react and our these messages from the back end you don't really know when they're going to come they could be out of order but it could be different components because it's a single boss that all these messages coming and so we were actually pretty confused in terms of how do you update your friend and state and so what we did there was an example that say that the web app and you have a notification system that gives you a drop down with all the new messages and then you have a feed which tells you all the new elements that are inserted into your feet system and our WebSocket handler gets all these messages and then use standard queries are all on messaging so you essentially implement the on messaging system on the front and to dispatch these messages so too does a familiar with their how IOS apps are built there's a single bus and you get these messages and the dispatched through different views and these views are listened when the loaded and in there destroyed the handlers when they unload so the same kind of concept that way you're notification system and you feel a lot time directly into WebSockets is an abstraction layer there and for whatever reason it WebSockets is not supported so you can always fall back this is just architectural idea and had organize front end so problem number for debugging debugging testing all of this was that was a big challenge but because you cannot use coal to mark requests a lot of the GenGO our test clients and all that stuff doesn't look so what we did is our you know that example where the middleware that's utilize the messages we just stored that as our as our fixture so we were able to bring up a friend client and then feed messages from the back and based on this picture and and it's pretty important to keep that stream of messages on your back in the stream of messages received on the front and and pushed them board into a simple placed in a store to you can reconsign the message there being sent from the back in the messages that have been received from the front end and see if there are any gaps so without this unified view across the client and the server so it's kind of difficult to figure out what's going on it is another chrome is pretty awesome W S and I spent 2 weeks debugging trauma that suckers without knowing chrome has built in so you just click on the frames and this gives you a sequential list of all the messages received to the WebSocket if either outgoing or incoming no problem it just shows the 2 and just used or as a transport so you can you can inspected can provide what everyone chat it so there is that concludes that I my talk and now I'm open to questions the but few things the talk but in 1 of your earlier diagrams it looked like you were basically accepting the initial http requests the agents running the sequel query like on a different jangle box on worker somewhere on how are you able it is that true 1st of all and we do you like in
celery in the background or in
that 1 the Yale the right of those 2 separate Django web servers that's exactly right so we were offloading liquidate to uh celery Walker so how are you able to basically keep the WebSocket alive but when you move it from the initial machine I got the request to the celery web server so the Jaguar channels documentation recommends red it's as a persistent where so from any web server you can talk to a client no matter what actual web so it's connected to so it gives you a unified view of all the clients connected you mentioned that you an event bus on the front end with react but it did you did you something I like redox or what was that G. 0 1 4 for doing that we are just use something that build on GeoQuery GeoQuery event in emitters OK yeah I have a question um you mention and that the hiccup in the original deployment of when you're just using AJAX request response and I wonder how high you handle through that in this architecture we still need to know replace decoding that worker that's running the corre had had a panel deployment of the worker and that and that maybe still doing work a very good question so are deployment cycles are different for the GenGO ad and the celery workers the workers and it's OK to run with let's say the 1 of the calls and then you can actually do delayed deployment all new workers have version 2 and version 1 is still running no problem it's not you not killing the existing locus of 1 worker 1 instance of the workers 1 query to phylogenies you have had the get the static the data and their D disused to distill regulary TL to a post press database and then have them as unmanaged I know like the matter and managed by a Django models so that there's a connection to the front end them did you did that question makes sense so did you must be running sequel and some static type of data rate like if you're doing data analysis you know could be gigabytes of data via from flat files you loaded into pose grammars then do you somehow Intraspect and generate uh unmanaged models and the reason I say on managers because you don't want to of IEEE donor spoil any of the static data and next and we have some so yeah you know what I'm saying but managed confusing but it's systematic tag for the model to not netted migrate to this at the end of the Internet that you have to do migration port but when it readily Russian OK so the question was of the execute the sequel against some unknown schema and his question was do you import that's the mind you general models or does it you're clean sanitized actuated schema or not right because it could be on the and are the answer question is will manage any of our customers do they don't even touch a jangle are general knows and knows nothing about it and so we the truly send that raw text and that excuse sequel walks through ssh tunnel to the customer's database which they host so we don't we on import any malls going to is that they knew django our customers doing all of these in general in the back so the clear separation between our ap and the customers data model so make sense how did you solved authentication issue maybe you I answered and I just didn't hear it but you said that we were in sending the the cookies over and then you that I just maybe jumped ahead it's so there's a full section in the Django channels documentation on authentication but as if she would does it passes off the HTTP session to the GenGO session part channels sessions and that hand office done during connect and so the subsequent messages don't have any kind of far Cookie header or anything so but the general channels are condition goes into a lot of detail so are you just have to add some decorators Europe channel use essentially the you mention that 1 of the reasons you want to adopt a solution was found but the not the AM again of server load under the removal of the long poles and are you ready at the messages did this solve that problem he in any other way so we know we definitely partially solve the problem in the sense that we still have that big spike of Ajax requests but the difference now is that that full cycle there is less than 50 ms it's not a long-standing connections so you can connect 7 thousand you can open up 7 thousand connections to 50 ms each rather than having 7 thousand connections which are 3 minutes long that's the difference you mentioned you're using TCP load balancing and there so in in the TCP IP you're so essentially we are are you able to get the same all level of affinity that you would need in sort of a higher level scheme for load balancing it such as HTTP and cookie insertion based affinity it that's been a challenge for us our stick session is an unsolved problem in this scenario are another challenge that we have is the IP addresses of the points keep changing and so you can't really reconnect to the same hour our websocket connection so I think that's the reason why there are lot of disconnect and reconnect I haven't gotten to the bottom of that yet but that is definitely an unsolved problem in this scenario how do you manage a lifetime's of connections Kazakh imagine that the reconnection and the example that he showed could look very similar to a user say on with her exciting and I don't I don't actually want any updates which which portion which life cycle from the right up to the back and or the back into the customer's database so that the code that would suck connections if uh if they go away they también tentially going away or could be a connection issue so when they go away it unloads the absolute disconnect that socket I right now there is no way for you to just go offline essentially right there's no way to go off line of the rear you know pretty aggressive in reconnecting and trying to reconnect so we have an exponential backoff there just in case the back and is actually down Our then you wanna like camera you back in with every trying to reconnect every 15 ms or 5 milliseconds to back off their fathers 1 2nd 2 seconds for 2nd this like Gmail the g values see is reconnecting and 3 seconds and if it can reconnect reconnecting in 7 seconds and the connecting plots against reconnecting tomorrow and so on right so the same kind of the thank you again for sharing your expertise of a few the higher end
thank and