Hi!
We're using Spear in production and are noticing that performance might be less than ideal. We're not sure where exactly the problem resides - Spear, EventStoreDB or the network.
Our flow is as follows:
- load events from a stream (using
SpearClient.stream!)
- build the current state from the events
- append new events to the same stream (using
SpearClient.append)
Our SpearClient module is literally as simple as this:
defmodule SpearClient do
use Spear.Client, otp_app: :our_app
end
All this takes consistently approx 100-120 ms on production, and almost as much locally. Which seems rather slow.
- We have our app deployed on fly.io and the EventStoreDB instance on Event Store Cloud (deployed on Google Cloud in the same geographic region).
- Locally EventStoreDB runs via docker compose (in OrbStack).
When isolated to just the Spear calls (no logic of our own), we see the following on localhost:
SpearClient.stream!("stream_with_300_events") |> Enum.into([]) - between 40 and 60 ms
SpearClient.stream!("stream_with_20_events") |> Enum.into([]) - between 20 and 40 ms
- `SpearClient.append(new_events, "stream_with_300_events", expect: last_known_revision) - around 10ms
- `SpearClient.append(new_events, "stream_with_20_events", expect: last_known_revision) - <5ms
In production append takes typically a bit less than stream! + Enum.into([], but still hovering around 50ms in majority of cases.
As a side note, relatively simple queries to PostgresSQL (deployed on Google Cloud too) only take around 3-5 ms on average.
Would it be possible to confirm that these timings are higher than expected? Anything else we could debug or try to speed it up?
Thanks in advance for any advise!
Hi!
We're using Spear in production and are noticing that performance might be less than ideal. We're not sure where exactly the problem resides - Spear, EventStoreDB or the network.
Our flow is as follows:
SpearClient.stream!)SpearClient.append)Our
SpearClientmodule is literally as simple as this:All this takes consistently approx 100-120 ms on production, and almost as much locally. Which seems rather slow.
When isolated to just the Spear calls (no logic of our own), we see the following on localhost:
SpearClient.stream!("stream_with_300_events") |> Enum.into([])- between 40 and 60 msSpearClient.stream!("stream_with_20_events") |> Enum.into([])- between 20 and 40 msIn production
appendtakes typically a bit less thanstream! + Enum.into([], but still hovering around 50ms in majority of cases.As a side note, relatively simple queries to PostgresSQL (deployed on Google Cloud too) only take around 3-5 ms on average.
Would it be possible to confirm that these timings are higher than expected? Anything else we could debug or try to speed it up?
Thanks in advance for any advise!