Repository navigation
perf(devserver): Start the web without loading the app or waiting for Kafka - #130860
Merged
Merged
Conversation
… Kafka The devserver loaded all of Sentry only to read settings and ask the eventstream backend whether it needs the post-process forwarder, then created Kafka topics before starting anything. It now loads settings only, decides the forwarder from SENTRY_EVENTSTREAM, and creates topics in a background thread that waits for Kafka. Consumers wait for the topics, since one that subscribes to a missing topic crashes. A topic failure prints its traceback and stops the devserver. The children validate the backends, since this process no longer does. Co-Authored-By: Ming Chen <ming.chen@sentry.io>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b0728dc. Configure here.
Granian forks its workers, so the in-process path creates topics synchronously instead of leaving Kafka client threads alive across the fork. Exit after the in-process server stops, rather than falling through into honcho and starting a second server.
Topic creation now prints one "waiting for kafka at <host>" line, silences librdkafka's per-attempt connect errors, and gives up after 60s with the traceback, which stops the devserver. The --no-watchers path creates topics in a forked child started before Granian forks its workers, so no worker copies Kafka client threads and the web no longer waits for topics. The tests import from sentry.runner.commands.devserver directly, so selective testing picks them for any change to devserver.py. Co-Authored-By: Ming Chen <ming.chen@sentry.io>
mchen-sentry
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

sentry devserverloaded all of Sentry (~7–10 s) only to read settings, pick its daemons, and create Kafka topics. Then the web server started and loaded all of Sentry again. On a fresh boot, Kafka usually answers only at about that moment, so the web also waited for Kafka.Now the devserver:
settings_configurationdecorator (configure(settings_only=True)). The paths that serve from this process (--debug-server, and no daemons) still run the fullconfigure().SENTRY_EVENTSTREAM, because asking the backend imports models. A test checks the list against everyEventStreamsubclass'srequires_post_process_forwarder().UNKNOWN_TOPIC_OR_PART, and that stops everything. honcho runs commands throughsh, so each consumer command first waits for.artifacts/devserver-kafka-topics-ready.SENTRY_SKIP_BACKEND_VALIDATIONfor its children.Time from launch to the first
200on/auth/login/through rsbuild on :8000, measured in a sandbox with devservices up (3 starts each):With every topic deleted and
--workers --occurrence-ingest, the web answered in 10.3 s. All topics existed 19 s after launch, and only then did the consumer start and get its partitions. A bad cluster mapping printed itsKeyErrortraceback to the terminal anddev.log, then stopped every process.via Ming Chen.
--
View Session [Sentry]