diff --git a/docs/benchmark.md b/docs/benchmark.md new file mode 100644 index 00000000..e6a4d939 --- /dev/null +++ b/docs/benchmark.md @@ -0,0 +1,92 @@ +# Benchmarking the performance + +Apisonator is designed to process a lot of requests quickly and sometimes minor changes or changes in the underlying libraries results in significant performance degradation. + +Due to differences in the underlying hardware, a fixed numbers can't be given. Always compare performance with and without your changes. + +Another thing to keep in mind is that a local redis has a significantly lower latency than a remote one. So a real world setup benchmark will be much more valuable. For example locally the `sync` mode will be very much comparable to `async`. But in reality `sync` is much slower at present. + +## Check worker performance locally + +Run the following rake task with `CONFIG_REDIS_ASYNC=false` or `CONFIG_REDIS_ASYNC=true` depending on which mode your changes affected. + +``` +CONFIG_REDIS_ASYNC=true CONFIG_QUEUES_MASTER_NAME=localhost:6379/5 CONFIG_REDIS_PROXY=localhost:6379/6 time -- bundle exec rake --backtrace bench[worker/worker_bench.rb] +``` + +## Check listerner performance locally + +### Obtain existing keys and metric + +This is useful if you later want to compare performed requests to the reported requests in porta. +Alternatively you can generate fake entries into apisonator database. + +Open porta, choose a provider and get the keys through the UI. + +You can use also use porta rails console. +```ruby +Account.all.pluck :org_name, :id +Account.find(2).provider_key +Account.find(2).services.first.id +Account.find(2).services.first.cinstances.take.user_key +``` + +To ensure the provider data is synced in apisonator, run this in porta repo: +``` +PROVIDER_ID=2445584351329 bundle exec rake backend:storage:rewrite +``` + +### Create fake keys and metric + +This approach is quicker and doesn't require porta to be running. + +With ruby +``` +export CONFIG_REDIS_ASYNC=false +bundle exec ruby -Ilib/ -r3scale/backend.rb <