Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

633
Visualizações
Real-time update on Django application using MySQL <> WebSocket

I need to continuously get data from a MySQL database which gets data with an update frequency of around 200 ms. I need to continuously update the data value on the dashboard text field.My dashboard is built on Django.

I have read a lot about Channels but all the tutorials are about chat applications. I know that I need to implement WebSockets which will basically have an open connection and get the data. With the chat application, it makes sense but I haven't come across anything which talks about MySQL database.

I also read about mysql-events. Since the data which is getting in the table is from an external sensor, I don't understand how I can monitor a table inside Django i.e whenever a new row is added in the table, I need to get that new inserted based on a column value.

Any ideas on how to go about it? I have gone through a lot of articles and I couldnt find something specific to this requirement.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Build a microservice for Websockets connections

Another way to implement such a feature - is to build a standalone WebSocket microservice.

Monolyth architecture isn't what you need here. Every WebSocket will open a connection to the Django (which will be behind reverse proxy and server: NGINX and Gunicorn ex.). If your client opens two tabs in the browser you will get 2 connections etc...

My recommendation is to modify the tech stack (yes, I'm a huge fan of Django, but there are many cool solutions in building WS):

  1. Use Starlette ready for production framework with build-in WebSockets: https://www.starlette.io/websockets/
  2. Use uvicorn.workers.UvicornWorker for Gunicorn to manage your ASGI application: this is only 1 line of code, like gunicorn -w 4 -k uvicorn.workers.UvicornWorker --log-level warning example:app
  3. handle your WebSocket connections and use examples to request updates from the database: https://www.starlette.io/database/
  4. Use super simple Javascript code to open the connection of the client-side and listen for updates.

So your models, templates, the view will be managed by Django. Your WebSocket connections will be managed by Starlette in a native async way. If you're interested in such an option I can make detailed instructions.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda