Developing for Web Services
4 Questions to Ask Yourself Before Developing with Web Services
If you are developing a site today, odds are you are integrating with at least one web service. Whether it’s a search application, CRM, AMS, or some other homegrown application, your website most likely relies on an external web service. However, without giving proper consideration to how your site will interact with that web service, it could negatively impact the performance and availability of your website. Here are four questions you should ask yourself before integrating any web service.
What if the service is unavailable?
How you handle a web service that is erroring out or not responding is key to the health of your site. You must decide whether your page or component should result in an error or gracefully degrade to remove any functionality that is dependant on the service. There is also some overhead associated with catching errors; if you expect a large volume and/or frequent calls to the service, you may want to consider implementing the Circuit Breaker pattern to avoid continuously querying an unavailable service.
How much latency is too much?
There is a certain amount of overhead in calling web services. It is important to decide upfront how much latency is tolerable. Accepting too much latency may cause your site to appear slow or cause requests to queue while waiting for web service calls to return. Be too intolerant, and you might terminate requests prematurely, causing unnecessary errors. An acceptable amount of latency may depend on the feature or particular call you are making to the service. What will your site do if your threshold is reached? Will it treat the service as if it is unavailable (Question 1)? You may consider calling the service asynchronously via async/await. This won’t help slow page loads, but it will help to avoid request queuing, thereby maintaining site availability.
Am I making the fewest calls possible?
As mentioned in Question #2, there is a certain amount of overhead and latency that comes with each web service call. This question is meant to make us consider whether or not we are making as few calls as possible, and if we are properly considering which service calls we can safely cache the responses of.
How will I know if the web service contract changes?
A common practice in website development is to have multiple environments in which to test your work before it reaches production. Often, we point to development versions of web services, as well (e.g. integrating with a CRM like Salesforce). What if expected changes are not deployed (or are deployed early) to the production instance of the web service? You might find your website down, having spent hours debugging code, only to realize later on that the web service contract changed (or didn’t change), unexpectedly. Having a suite of integration tests to validate the input and output of your web service calls, and ensure that their behavior match your expectations will help to quickly identify the root of your issues.
If done correctly, integrating with web services is a powerful tool for enhancing your website. If not, it could result in poor experience for you and your users. Before your next integration, if you consider these 4 questions, you will have a plan that will keep the health and stability of your site in mind.