You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: lib/broadway.ex
+19-32
Original file line number
Diff line number
Diff line change
@@ -609,55 +609,42 @@ defmodule Broadway do
609
609
610
610
## Configuration Storage
611
611
612
-
Broadway stores configuration globally in a chosen storage method. Broadway comes with two configuration storage options:
612
+
Broadway stores configuration globally in a chosen storage method.
613
+
Broadway comes with two configuration storage options:
613
614
614
615
- `:persistent_term`, the default.
615
616
- `:ets`
616
617
617
-
618
-
619
618
### Persistent Term
620
619
621
-
A `:persistent_term` backed configuration storage, which is the default storage option used. Configurations are not deleted when the Broadway server process goes down, so as to avoid a global GC.
620
+
This is the most efficient option for static Broadway pipeline definitions,
621
+
as this option never deletes the Broadway configuration from storage:
The speed of storing and updating using `:persistent_term` is proportional
628
+
to the number of already-created terms in the storage. If you are creating
629
+
several Broadway pipelines dynamically, that may affect the persistent term
630
+
storage performance. Furthermore, even if you are restarting the same pipeline
631
+
but you are using different parameters each time, that will require a global
632
+
GC to update the `:persistent_term` configuration. If you are starting Broadway
633
+
pipelines dynamically, you must use `:ets`.
634
+
627
635
### ETS
628
-
An ETS-backed configuration storage. Only use this if performance improvements over the default `:persistent_term`-based storage is needed.
629
636
637
+
An ETS-backed configuration storage, useful if Broadway pipelines are
638
+
started dynamically.
630
639
To use this configuration storage option, set your application config.exs as so:
631
640
632
641
```elixir
633
-
config Broadway, config_storage: :ets
634
-
```
635
-
636
-
To pass options, use a tuple with a keyword list as so:
637
-
638
-
```elixir
639
-
config Broadway,
640
-
config_storage: :ets,
641
-
config_storage_opts: [
642
-
table_name: :my_table
643
-
]
642
+
config :broadway, config_storage: :ets
644
643
```
645
644
646
-
Accepted options:
647
-
- `:table_name` - configure the table name. Defaults to `:broadway_configs`.
648
-
649
-
#### Performance Improvements over `:persistent_term`
650
-
`:persistent_term` will trigger a global GC on each `put` or `erase`. For situations where there are a large number of dynamically created Broadway pipelines that are created or removed, this may result in the global GC being triggered multiple times. If there is a large number of processes, this may cause the system to be less responsive until all heaps have been scanned.
651
-
652
-
As `Broadway.ConfigStorage.PersistentTerm` does not perform an erase when the Broadway server process goes down, it may result in memory buildup over time within the `:persistent_term` hash table, especially when dynamic names are used for the Broadway servers.
653
-
654
-
Furthermore, the speed of storing and updating using `:persistent_term` is proportional to the number of already-created terms in the hash table, as the hash table (and term) is copied.
655
-
656
-
Using `:ets` as the config storage will allow for a large number of Broadway server configurations to be stored and fetched without the associated performance tradeoffs that `:persistent_term` has.
657
-
658
-
659
-
660
-
645
+
Using `:ets` as the config storage will allow for a dynamic number of Broadway server
646
+
configurations to be stored and fetched without the associated performance tradeoffs
0 commit comments