“Going Viral” used to be a bad thing that caused long waits in doctor’s offices at the epicenter of an epidemic. Now it’s something everyone hopes for, from Facebook fan page hosts to YouTube video directors. Mobile application providers also yearn to go viral, even though it brings with it some added risk. While your marketing team is striving for virality, DevOps really needs to be striving for virility.
The best way to make sure your mobile application doesn’t come unglued is by writing robust API tests for all APIs you depend on, including third-party APIs, then leveraging those same tests in your production environment. Essentially, always be ready for that moment when someone on your team shouts, “We’ve gone viral!”
With increased traffic comes increased strain on the application. Those APIs that worked well in development will be facing everything real life and heavy traffic can throw at them. That’s why, in addition to fully testing your own code, it is critical to write comprehensive API tests that anticipate the real-world scenario of thousands, if not millions, of Web users beating a path to your door.
APIs are bridges connecting parts of that path. If one or more of them wash out, your viral momentum may end suddenly as users give up and go elsewhere. With mobile apps, performance expectations are far greater than with Web applications because the users are not stationed in front of a computer and are often multi-tasking with the expectation of quick response and delivery. With these higher expectations and the increased competition in the mobile space, a robust API testing and monitoring strategy is essential in making sure you can identify and respond to problems quickly.
Writing Great API Tests
Here are some tips for writing robust API tests:
- Agile teams have the benefit of cross-functional communication at all stages of development. Solicit input from everyone and invite all to review test. This will more closely resemble the variety in that real-world tsunami that could swamp you if you are not prepared.
- Make sure the test script is easily accessible to every member of the team, including Operations. This will help smooth the transition to API monitoring. Using compatible products (like soapUI for testing and AlertSite for monitoring) lets you easily upload API test projects into your production monitoring environment.
- Make sure you document the API test project well, including the API declarations and nuances, if any.
- Focus on the most used API functions and work your way down as time permits.
- For each test case, prioritize its risk, rating how often it could fail and how severe the consequences might be. In the fast-paced Agile environment, this will help testers to prioritize testing.
- Design some tests to fail. This can cause the API to send a helpful de-bugging message that contains otherwise inaccessible information.
Creating Dependable API Monitors
Guess who is the first to find out that an app has gone viral? Oh yeah, the person monitoring the production environment. You’re the first to see the traffic surge, usually by discovering all the areas of the application that are buckling under the onslaught. So, after your development team hands off the application get them to hand over the API tests they ran so you can convert them to production monitors. They are the experts on the APIs, whether they wrote them or integrated with them from another source, and they are best equipped to write the monitor that will target the area of highest risk.
Here are some tips for creating dependable API monitors:
- Re-use your API tests. Those API tests you ran in development are key to your success; your development team knows what to test and how to test it. A passing API test sets the standard for how your dev. team expects the API to perform. While you may not need all of the steps they’ve put into the test project, you can use it as a starting place to tailor your monitors.
- Predictable data is important; you don’t want to build a monitor that has to be adjusted every few days because the data returned by the API isn’t predictable. In some cases, you may need to determine that the only valid monitoring you can do on an API is whether it provides a response of any kind rather than identifying a specific response.
- Prioritize the API monitors you run. You don’t need to run every monitor at the same frequency. Depending on how often an API is called in your application and how important it is to the success of your application, you may want to make it a lower priority and run it less frequently.
- Plan the thresholds you want to be alerted about. You are going to get a lot of valuable information from your API monitoring that may not require any immediate action on your part. It’s important to set thresholds in your monitors that will alert you appropriately if a major error occurs but it’s just as important to set thresholds that identify when an API’s performance isn’t disastrous but also isn’t optimal.
Building Better Apps
Use the data you get from your monitors to make smarter decisions about your application. The mobile industry is highly competitive; having an app that works isn’t enough anymore – your app needs to be better than the competition’s apps. Performance is a major differentiator in today’s market. System administration and monitoring is no longer just about up/down – it’s about quality metrics that give your team an edge in the market. Make sure you are reviewing the output from your monitors with the rest of your development team so you can make the most of the API monitors you’ve put in place.