Skip to content

Commit 6150401

Browse files
committed
Merge pull request #21 from duomark/max_sessions
TS-1025 Make max_sessions be a multiplier per cassandra node
2 parents 37cca47 + b6707b4 commit 6150401

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/elysium.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{application, elysium,
22
[
33
{description, "Elysium for Cassandra"},
4-
{vsn, "0.1.6i"},
4+
{vsn, "0.1.6j"},
55
{id, "elysium"},
66
{registered, [elysium_sup, elysium_connection_sup]},
77
{applications, [kernel, stdlib]},

src/elysium_default_config.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ cassandra_send_timeout() -> 1000.
8282

8383
-spec cassandra_max_sessions() -> max_sessions().
8484
%% @doc Allow a max of 16 simultaneous live Cassandra sessions.
85-
cassandra_max_sessions() -> 5.
85+
cassandra_max_sessions() -> 3.
8686

8787
-spec cassandra_max_checkout_retry() -> max_retries().
8888
%% @doc Retry up to 20 times when session queue races occur.
89-
cassandra_max_checkout_retry() -> 3.
89+
cassandra_max_checkout_retry() -> 5.
9090

9191
-spec cassandra_session_decay_probability() -> decay_prob().
92-
%% @doc Kill a live session 1000 out of 1M times it is used.
93-
cassandra_session_decay_probability() -> 1000.
92+
%% @doc Kill a live session 100000 out of 1B times it is used.
93+
cassandra_session_decay_probability() -> 100000.
9494

src/elysium_queue.erl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,11 @@ terminate(Reason, _State_Name,
190190
%% @private
191191
%% @doc Move to 'ACTIVE' if requested, otherwise stay in 'INACTIVE' state.
192192
?inactive(activate, _From, #ef_state{config=Config, connection_sup=Conn_Sup} = State) ->
193-
Max_Sessions = elysium_config:session_max_count(Config),
193+
Max_Sessions = elysium_config:session_max_count (Config),
194+
Lb_Queue_Name = elysium_config:load_balancer_queue (Config),
195+
Num_Nodes = ets_buffer:num_entries_dedicated (Lb_Queue_Name),
194196
_ = [spawn_monitor(elysium_connection_sup, start_child, [Conn_Sup, [Config]])
195-
|| _N <- lists:seq(1, Max_Sessions)],
197+
|| _N <- lists:seq(1, Max_Sessions * Num_Nodes)],
196198
{reply, Max_Sessions, ?active, State};
197199
?inactive(_Any, _From, #ef_state{} = State) ->
198200
{reply, ok, ?inactive, State}.
@@ -227,9 +229,11 @@ terminate(Reason, _State_Name,
227229
%% @private
228230
%% @doc Activate if requested, from the 'INACTIVE' state.
229231
?inactive(activate, #ef_state{config=Config, connection_sup=Conn_Sup} = State) ->
230-
Max_Sessions = elysium_config:session_max_count(Config),
232+
Max_Sessions = elysium_config:session_max_count (Config),
233+
Lb_Queue_Name = elysium_config:load_balancer_queue (Config),
234+
Num_Nodes = ets_buffer:num_entries_dedicated (Lb_Queue_Name),
231235
_ = [spawn_monitor(elysium_connection_sup, start_child, [Conn_Sup, [Config]])
232-
|| _N <- lists:seq(1, Max_Sessions)],
236+
|| _N <- lists:seq(1, Max_Sessions * Num_Nodes)],
233237
{next_state, ?active, State};
234238
?inactive(_Other, #ef_state{} = State) ->
235239
{next_state, ?inactive, State}.

0 commit comments

Comments
 (0)