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

144
Visualizações
WebSockets streaming third party API to multiple subclients

We have a data-driven application where our backend continuously fetches data from a third party server and then feeds it over websocket to our clients frontend. Now the issue is that whenever each client will come the same data has to be fetched twice for both of them which is deemed unnecessary. Suppose the following code (in PHP for example)

$apiData = file_get_contents('https://third-party-api.com/feed/data.json');
$sockets->send($apiData);

Now our client on frontend can request this data via websockets.But the issue is if the second client connects, then the same data is downloaded twice.

Note: We do not want to save data (no database or anything at all because its of no use to save data).

Is there a method where if two clients are connected then the same feed can be sent to both of them?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to send the data from the API it to two clients who are not both connected at the time the data is fetched then you'll need to cache the data somewhere

For example a Redis cache (or similar technology) is one option if you don't want to use a database or other persistent storage.

about 4 years ago · Juan Pablo Isaza 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