diff options
author | Ingela Anderton Andin <[email protected]> | 2016-06-03 17:00:17 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2016-06-13 13:11:03 +0200 |
commit | 3415d9274a456a2ba6e3e321b591c4d518c0e2c8 (patch) | |
tree | a4755fa56b1fc11ee242de3287d4c22cd427048f /lib/ssl | |
parent | 523e048754f5086a6cc4fd9a250e1b495fc5b9b8 (diff) | |
download | otp-3415d9274a456a2ba6e3e321b591c4d518c0e2c8.tar.gz otp-3415d9274a456a2ba6e3e321b591c4d518c0e2c8.tar.bz2 otp-3415d9274a456a2ba6e3e321b591c4d518c0e2c8.zip |
ssl: Mitigate load increase when the whole session table is invalidated
Diffstat (limited to 'lib/ssl')
-rw-r--r-- | lib/ssl/src/ssl_manager.erl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ssl/src/ssl_manager.erl b/lib/ssl/src/ssl_manager.erl index 311dac4619..8ed29cc6b0 100644 --- a/lib/ssl/src/ssl_manager.erl +++ b/lib/ssl/src/ssl_manager.erl @@ -67,6 +67,7 @@ -define(CLEAN_SESSION_DB, 60000). -define(CLEAN_CERT_DB, 500). -define(DEFAULT_MAX_SESSION_CACHE, 1000). +-define(LOAD_MITIGATION, 10). %%==================================================================== %% API @@ -196,10 +197,12 @@ register_session(Port, Session) -> %%-------------------------------------------------------------------- -spec invalidate_session(host(), inet:port_number(), #session{}) -> ok. invalidate_session(Host, Port, Session) -> + load_mitigation(), cast({invalidate_session, Host, Port, Session}). -spec invalidate_session(inet:port_number(), #session{}) -> ok. invalidate_session(Port, Session) -> + load_mitigation(), cast({invalidate_session, Port, Session}). -spec invalidate_pem(File::binary()) -> ok. @@ -719,3 +722,11 @@ invalidate_session_cache(undefined, CacheCb, Cache) -> start_session_validator(Cache, CacheCb, {invalidate_before, erlang:monotonic_time()}, undefined); invalidate_session_cache(Pid, _CacheCb, _Cache) -> Pid. + +load_mitigation() -> + MSec = rand:uniform(?LOAD_MITIGATION), + receive + after + MSec -> + continue + end. |