Cold shape requests are slow when PostgreSQL has higher network latency
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- elixir, postgresql
- Ambito
- databases, performance
Direzione di ricerca
Start with the display_settings/0 implementation in the referenced Electric module and snapshot_query.ex, where the issue says Postgrex.query! runs each setting separately. Trace the snapshot transaction and compare cold request latency with the reproduction against a higher latency PostgreSQL connection. The suspected cause is unconfirmed; done means establishing whether combining the settings reduces sequential database calls and cold request latency.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I was testing Electric 1.8.1 and seeing a noticeable difference in cold shape request latency depending on how close Electric is to PostgreSQL. Database is hosted on Neon cloud.
- Local Electric → PostgreSQL (~60ms DB latency): request takes around 1.5 seconds
- Electric deployed closer to PostgreSQL (~20 ms DB latency): request takes around 300 ms
Warm requests return in a few milliseconds.
Reproduction
-
Run Electric against PostgreSQL with noticeable network latency.
-
Request a new shape with offset=-1 and a previously unused filter value:
curl -sS -G 'http://localhost:3000/v1/shape'
--data-urlencode 'table=public.example'
--data-urlencode 'offset=-1'
--data-urlencode 'where=run_id = $1'
--data-urlencode 'params[1]='
--output /dev/null
--write-out 'TTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' -
Repeat with different filter values to measure cold requests, then repeat the same requests to compare warm responses.
Suspected cause
The snapshot setup appears to make several sequential database calls, so network latency could account for a significant part of the delay.
Trace for a request that took 1.33s shows that span shape_snapshot.set_display_settings took 595ms, and shape_snapshot.query_fn took 414ms.
In particular, display_settings/0 in postgres.ex (https://github.com/electric-sql/electric/blob/%40core%2Fsync-service%401.8.1/packages/sync-service/lib/electric/postgres.ex) defines five statements:
SET bytea_output = 'hex';
SET DateStyle = 'ISO, DMY';
SET TimeZone = 'UTC';
SET extra_float_digits = 1;
SET IntervalStyle = 'iso_8601';
snapshot_query.ex (https://github.com/electric-sql/electric/blob/%40core%2Fsync-service%401.8.1/packages/sync-service/lib/electric/postgres/snapshot_query.ex) executes these through an Enum.map, calling Postgrex.query! separately for each statement inside the snapshot transaction.
Could these settings be applied in one database call, for example using a single SELECT with multiple set_config calls? I haven't tested that yet, so this is only suspected, not confirmed.
- Lingua principale
- TypeScript
- Stelle
- 10.4k
- Fork
- 394
- Merge medio
- 22h 11m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di electric-sql/electric
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
electric-sql/electric#4830 ·
I maintainer di solito rispondono entro 1 giorno
-
@electric-sql/client throws SecurityError on import when the browser blocks site storage (typeof localStorage outside try)Forse già presa @mohanedmoh l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
electric-sql/electric#4826 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agents-chat-starter: spawn PUT goes to the durable-streams proxy, so no entity is created and agents never wakeForse già presa @adityavkk l’ha presa 103 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
electric-sql/electric#4687 ·
I maintainer di solito rispondono entro 1 giorno
-
Listen IP addressApertafeature request triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
electric-sql/electric#4150 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
ArrayDecoder doesn't handle escaped backslashes in quoted PostgreSQL array elementsForse già presa @cpruijsen l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
electric-sql/electric#3708 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di electric-sql/electric
Issue simili
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commitForse già presa @myOmikron l’ha presa oggi. Apertabug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Windows: mio 1.2.3 named-pipe use-after-free panics the native IPC broker and hangs every toolApertaplatform:windows tool triaged wontfix
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
nicolettas-muggelbude/RechnungsFee#448 ·
I maintainer di solito rispondono entro 1 giorno
-
Android bug feature/error-tracking react-native team/error-tracking
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PostHog/posthog-js#5310 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno