Skip to content

Instantly share code, notes, and snippets.

@simonmacmullen
Created March 9, 2015 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmacmullen/0e4c88cc3ffed2f74f3a to your computer and use it in GitHub Desktop.
Save simonmacmullen/0e4c88cc3ffed2f74f3a to your computer and use it in GitHub Desktop.
Performance testing RabbitMQ LDAP plugin
I applied this patch to the server:
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index 41c54b0..a0feb33 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -136,9 +136,16 @@ check_vhost_access(User = #user{username = Username,
fun({Mod, Impl}, ok) ->
check_access(
fun() ->
- rabbit_vhost:exists(VHostPath) andalso
- Mod:check_vhost_access(
- auth_user(User, Impl), VHostPath, Sock)
+ Count = 100,
+ {T, [R|_]} =
+ timer:tc(fun() ->
+ [Mod:check_vhost_access(
+ auth_user(User, Impl),
+ VHostPath, Sock) ||
+ _ <- lists:seq(1, Count)]
+ end),
+ io:format("Vhost check took ~pus~n", [T / Count]),
+ rabbit_vhost:exists(VHostPath) andalso R
end,
Mod, "access to vhost '~s' refused for user '~s'",
which runs each vhost access query 100 times, and prints the average time taken in microseconds.
I then did:
$ sudo tc qdisc add dev lo root handle 1:0 netem delay 10msec
to impose a 10ms latency on localhost (where my LDAP server is), then just ran PerfTest to see the timings.
To remove the localhost latency, do:
$ sudo tc qdisc del dev lo root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment