Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate subscription process after inactivity #214

Merged
merged 3 commits into from
Aug 11, 2020

Conversation

slashdotdash
Copy link
Member

@slashdotdash slashdotdash commented Aug 11, 2020

Add the :subscription_hibernate_after event store config setting used by subscription processes so they will automatically hibernate to save memory after a period of inactivity.

Hibernating a process will also force a garbage collection of the process' memory. As soon as a new message is received in the process mailbox the process will be resumed. This should have minimal impact on latency but can help to reduce memory leaks caused by large binaries.

By default subscription processes will be hibernated after 15 seconds of inactivity. This should provide a reasonable trade-off for minimising memory usage without affecting latency when the processes are busy. Setting the configuration value to :infinity will disable this behaviour.

Example configuration

# config/config.exs
config :my_app, MyApp.EventStore,
  serializer: EventStore.JsonSerializer,
  username: "postgres",
  password: "postgres",
  database: "eventstore",
  hostname: "localhost",
  subscription_hibernate_after: :timer.seconds(15)

Add the `:subscription_hibernate_after` event store config setting used by subscription processes so they will automatically hibernate to save memory after a period of inactivity.

Hibernating a process will also force a garbage collection of the process' memory. As soon as a new message is received in the process mailbox the process will be resumed. This should have minimal impact on latency but can help to reduce memory leaks caused by large binaries.
@slashdotdash slashdotdash merged commit 8a42645 into develop Aug 11, 2020
@slashdotdash slashdotdash deleted the feature/process-hibernate-after branch August 11, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant