fluent / fluent/fluent-logger-ruby

Logging messages can block

Aperta
#30 10 commenti 5 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Ruby
Stelle
256
Fork
77
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

This gem can block execution, effectively allowing a website to be DOS'd, if too many messages are sent at the same time. The TCPSocket is set to be synchronous, so the only buffering of messages is done in the kernel. But writes to the socket use `write` instead of `write_nonblock`, so if the kernel buffer fills up the write will block and the ruby thread being executed will just need to wait until data is cleared from the kernel buffer.

Compounding the issue, there is only one TCPSocket connection for all threads of a process. If a web app uses puma or some other kind of threaded model, then as soon as the kernel buffer fills up all threads will need to wait until buffer room is freed up.

To partially solve this issue, I think the write needs to be turned into a write_nonblock. The gem could then detect overflows and discard messages when that happens. It could also buffer some messages if they overflow, but that would just be a nicety.

To solve the issue further, there probably should be a separate connection per thread. That would allow for better scalability of socket buffering when comparing a single threaded process and a process with lots of threads trying to write messages. But this is also just a nicety on top.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia individuando il percorso di scrittura di TCPSocket e leggendo come la singola connessione viene condivisa tra i thread. Riproduci o testa il comportamento quando il buffer del kernel si riempie, quindi verifica che la gestione selezionata impedisca il blocco delle chiamate a logger, preservando al contempo il comportamento previsto dei messaggi. L’issue non indica alcun file né test, quindi è necessaria una ricerca nell’intero repository.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
ruby
Ambito
observability-sre
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.