Mobile performance testing using Jmeter & Terraform - getting started

Everyone has performance and scalability on their minds these days, so I am working on a project to bring more visibility to our bottlenecks.  The project will center around simple 'user scenarios':
  • We send a huge batch of push notifications, and a subset of users will open the app.  That simple action actually does a bunch of stuff, like authentication, refreshing feeds, and so on.
  • We make a change that dumps auth, and every user has to log in fresh.
  • We add an endpoint as part of a marketing effort (say, a news page), and a push notification lets users know this new thing is a thing.  The endpoint gets 100k hits in 5m.  Does it survive?
In all these scenarios you are dealing with read-only traffic, and nothing super fancy to put together.

Nobody here really knows much about performance testing (aside from previous experiences discovering that mass effort was not worth it, which I agree with), so I wanted to make a point of not turning this into a behemoth.  What we really wanted to get out of this:
  1. Better understanding of how our apps function in real-world user scenarios
  2. Basic understanding of how our ecosystem reacts to mass user scenarios
  3. Some experience under our belts using the tooling
We (me and QA folk) sat down for an hour and dialogued, ended up diagramming a few basic user scenarios that everyone agreed on.  Then - ok, how do we reproduce this?  Well, you sniff network traffic.  Haha, seriously.  A mobile app is simply HTTP requests flying around, once it leaves your phone, and your middleware apps are just listening for that.  So to reproduce user load, you need a way to generate a lot of very similar HTTP sessions.

Jmeter was 'the thing mentioned most', both by co-workers and Google, so I started there.  After getting it running and using an old iPhone we had sitting around, I slowly quickly realized a few things:
  • Jmeter's UI is kinda funny - the icon layout to expand/collapse is not the usual + sign.  It took an embarassingly long time to figure that out.
  • Getting a cert installed on an iOS device must be done via the NATIVE mail app.
  • Firewalls.
  • Understanding 'how Jmeter works' is a bit of a learning curve, but once you get it, seems so simple!
Once you saw the traffic coming in, it was pretty cool/the best feeling ever.

I then got to google about regex extractors and regexes for filtering URLs, and once that was figured out we were in business!  Thankfully the auth piece was already something fresh in mind as we were working on our API test framework and I had just finished getting auth working.

So now we have a functional Jmeter test plan, you spec more threads, it does more stuff.  Fancy feast.

Next up, we decided that vendors were the way to go!  But what kind of performance did we need from them?  Was 1000 concurrent users really 1000 concurrent users?  Turns out, not always!  Our starting point use case was: 2000req/s with 1000 concurrent users

With our simple/fast test plan, this would apparently overwhelm CPU/network, so we would probably only get the equiv of 300 concurrent users.  This meant enterprise, and that meant a trip back to the drawing board.  We were also, handily enough, working on learning Terraform, and said - HAY, WE CAN DO THIS!

Our tech stack for this is now:
  • Jmeter - build the test plan, record device traffic, etc
  • Terraform - builds a fresh VPC et al., master node, and slave nodes
  • Ansible - configures Jmeter on the nodes
  • Teamcity - will be the trigger point to build/execute all this jazz
  • S3 - where the reporting will go
  • Slack - where the reporting links will go
The only net-new tech here is Jmeter.  Fun!

The best part!  From the basic steps of figuring out 'how to performance test our apps' we have already learned valuable things that are now tickets that are being worked on to improve things.  We aren't even done the project and already it's delivering value - the best kind of project!

You'll note that no code has been published here, and that's intentional.  The only 'new' code we'll be writing here is in Ansible roles for remote Jmeter testing.  Even that will be pretty straightforward.

My key takeaways so far:
  • Thinking about something and writing stuff down is powerful
  • Taking the effort to get a bunch of people together and talk about a pressing issue and turn it into action is worth it (vs. it continuing to be 'the thing everyone is pattering around')
  • Exploratory learning of seemingly simple things can net great results - if the results are shared!
  • Terraform is crazy and horrible and wonderful
  • Jmeter is kinda creaky but seems to 'just work'

Will post up some results in the future.

Comments

Popular posts from this blog

Fixing duplicate SPNs (service principal name)

DFSR - eventid 4312 - replication just won't work

Logstash to Nagios - alerting based on Windows Event ID