Case Study


MyWebGrocer Brings Consumers and Grocers Together with API-Driven Personalized Ads Based on WSO2 Software

MWG Used Pre-Integrated WSO2 API Manager and WSO2 Business Activity Monitor Products to Manage APIs Driving its Digital Ads and Optimize System Performance

Increasingly, organizations are taking advantage of digital display advertising to strategically present personalized ads to consumers online. MyWebGrocer (MWG) is a leading provider of digital marketing solutions to the grocery and consumer packaged goods industries. The company offers an online grocery-shopping platform used by top retailers—with more than 10,000 retail locations in the US, and plans for expansion into Asia Pacific and Europe.

MWG delivers digital ads on its ad network and on public Internet sites that participate in other online networks, such as Google DoubleClick. To achieve this, the company reaches consumers online using both HTML5 dynamic media ads and Adobe Flash-based rich media ads.

Today, MWG relies on WSO2 API Manager and WSO2 Business Activity Monitor (WSO2 BAM) to effectively tailor digital ads to individual consumers while maintaining high availability and responsiveness even during peak periods. Through the use of caching, WSO2 API Manager is able to respond in just 8 milliseconds—meeting consumers’ demand for immediate access. Meanwhile, WSO2 BAM enables MWG to better understand its traffic patterns in order to tune the system, optimize its server infrastructure, and produce metrics for reporting.

Managing High Levels of API Traffic

MWG is a model for today’s API-driven economy. MWG connects online consumers with local grocers. With each online ad, an API is called to retrieve customized user data—information related to a particular consumer as well as one of the advertisers close to that buyer—in order to show products that might be interesting to that individual.

“The rich media ad calls an MWG API and dynamically pulls in data every time an ad is displayed to a consumer online, and in some cases each time a consumer clicks on the Web page,” explained Chuck Megivern, MWG senior software engineer. “As a result, this a really high-volume application for us.”

In order to handle this growing volume of consumers and related increase in data and interactions, MWG sought out an API management platform that could be easily customized to achieve high performance and scalability. At the same time, the company wanted a solution that was extensively pluggable to facilitate integration with its existing infrastructure.

A Distributed Design for High Volume

For MWG, the answer was an API Management platform based on the 100% open source WSO2 API Manager and WSO2 Business Activity Monitor.

WSO2 API Manager offers a complete, intuitive solution for publishing, managing, and subscribing to APIs, and it provides the flexibility to consume APIs and work with applications written in any language or framework.

WSO2 BAM complements WSO2 API Manager by providing insights into API usage patterns and performance. Incorporating the distributed data management and storage capabilities of Apache Cassandra, Apache Hadoop, and Apache Hive, it was built from the ground up for big data analysis.

“WSO2 API Manager and WSO2 BAM’s distributed design was very attractive, both capable and adaptable to our existing system,” Chuck recalled. “We also liked that the products were flexible, highly configurable, and based on open standards.”

"WSO2 API Manager and WSO2 BAM’s distributed design was very attractive, both capable and adaptable to our existing system."

Chuck Megivern,
Senior Software Engineer,

Today, MWG has implemented a distributed API Manager installation that serves:

  • Very high volume consumer browser API invocations
  • External business partners using MWG APIs
  • Internal MWG servers invoking MWG APIs

Consumer browser invocations, business partners, and internal MWG servers all use the same API gateways from WSO2 API Manager. The heterogeneous environment includes API consumers and API implementing servers that take advantage of Java, Java-related technologies, and Microsoft .NET. Both MWG’s application servers and its MySQL databases connect with WSO2 API Manager in order to access data via APIs, which the MWG system uses in determining how to tailor rich media ads for individual consumers in real-time, and link these users to the best grocers for their needs.

MWG uses Cassandra storage in WSO2 BAM as a “fast write” repository for data streams from the API gateways. The company also analyzes information about the system’s performance.

Maintaining High Availability

Because failure or degradation of the system is not an option, MWG, places a priority on load balancing and backup. At the front end, F5 load balancing appliances manage the level of network traffic going to the API gateways and application servers. MWG also relies on Nginx to not only preprocess static content but also load balance the application servers.

For backup, MWG implements circular replication with its MySQL databases. Additionally, the infrastructure supports up to N primary API gateways, which are connected to the BAM system. They are complemented by a single backup API gateway with no BAM connection. This way, if something unexpected happens to WSO2 BAM or the Cassandra Store behind it, MWG can still keep its WSO2 API Manager services up and running.

MWG also continually tests how a system is performing. For example, the company has adopted a health check in which an API is invoked from the F5 load balancer.

"The distributed nature of WSO2 API Manager is great—the Publisher is on a separate machine, so it doesn’t affect any of the live APIs."

Chuck Megivern,
Senior Software Engineer,

“This API health check is pretty important to us,” Chuck observes. “By invoking an API, we can make sure that the gateway is still there and working properly, that the key manager in WSO2 API Manager is good, and that the connection between the key manager and the database is all good, as well as if the application servers are functioning properly. With the health check API, we can be sure that we are healthy.”

WSO2 API Manager in Action

MWG takes advantage of all three WSO2 API Manager components: Gateway, Publisher, and Store—all of which can be deployed in different combinations to meet an organization’s scalability requirements. MWG has utilized this option to customize its own deployment of the solution. Most notably, it has Publisher and Store residing separately from the high-performance gateways.

“We want Publisher to keep publishing behind the scenes and not run on the same servers handling the fancy ad displays viewed by users,” Chuck explains. “This is why the distributed nature of WSO2 API Manager is great—the Publisher is on a separate machine, so it doesn’t affect any of the live APIs.”

MWG also takes advantage of WSO2 API Manager’s capabilities for geo-location, store circular queries, and caching. First, the company performs geo-location, based on zip code, to list local grocers by increasing distance. Then MWG gathers various store circulars based on keywords, which results in queries as well. In order to maintain performance, the company must cache the results of those queries. The database is loaded via extract, transform and load (ETL) processes.

“We have two caching points for our queries: geo-location and information about the store,” Chuck explains. “Memcached is used for items on sale in the store to improve performance.”

A typical example is when consumers visit a website displaying ads, in which the Google DoubleClick network delivers the ad to the consumer’s browser. There are multiple ads that can be displayed to the consumer, and each ad relates to a specific marketing message, the retailer identity and information about the retailer. MWG’s rich media ad determines the consumer’s zip code, and then an MWG API is called with the zip code, key contextual information, and retailer identity. The API returns with information on the nearest grocer and details for a relevant item available based on consumer context.

To support reporting of these and other actions, MWG relies on a WSO2 API Manager toolbox, which includes all necessary data stream definitions and Hive queries. Deploying the WSO2 API Manager analytics toolbox into WSO2 BAM servers allows these servers to capture and summarize the data, which is then exported to a relational database, so the information can be used for any purpose.

“The WSO2 API Manager toolbox made WSO2 BAM integration very easy, since it gives you the configuration and you don’t have to write any Hive scripts,” Chuck noted.

"With WSO2 BAM, we are able to gain instant access into understanding our API behavior patterns."

Chuck Megivern,
Senior Software Engineer,

WSO2 BAM Brings Performance Insights

MWG APIs need to be monitored continuously, so its system is constantly conducting scalable analysis of high volumes of data. By integrating WSO2 API Manager with WSO2 BAM’s monitoring and analytics capabilities, the company has been able to gain deeper insights into business activities.

“With WSO2 BAM, we are able to gain instant access into understanding our API behavior patterns,” says Chuck.

The use of WSO2 BAM has proven particularly valuable in understanding traffic patterns. Prior to the new system, MWG had a difficult time estimating its peak load with the total impression count provided by their marketing division. Immediately upon implementation, WSO2 BAM was able to summarize statistics and provide insights into business activities—evaluating minute-by-minute tracks, calls per minute, response per minute.

"We assumed that our workload would be random on average, but instead we discovered that it had a lot of bursts. That’s something we would not have known without using WSO2 BAM."

Chuck Megivern,
Senior Software Engineer,

“We assumed that our workload would be random on average, but instead we discovered that it had a lot of bursts,” Chuck recalled. “That’s something we would not have known without using WSO2 BAM.”

With the help of WSO2 BAM, MWG was also able to identify bottlenecks in the database and serving infrastructure, leading the company to implement Memcached for the caching infrastructure.

Chuck observed, “We didn’t see any bottlenecks in WSO2 API Manager—it was all in our serving infrastructure—but it was the integration between WSO2 BAM and WSO2 API Manager that helped us to understand what was going on.”

A Robust System Tuned for Rapid Response

The combination of WSO2 API Manager with Memcached has produced some impressive results. MWG has found that the processing time for an uncached API service is 150 to 200 milliseconds. However, with object caching the average API service time drops to just 8 milliseconds, and the cache hit-ratio is an impressive 85% to 90%. The fastest average service time is 376 responses per second at an average service time of just 5 milliseconds.

“Being able to achieve these responses at these times are what I am proud of most,” Chuck says. “The use case a company is trying to solve will determine what the response per second will look like. API Manager itself is robust and has a pretty high capacity handling some 100-400 requests per second per node, depending on the time of day.”

MWG currently is in the process of upgrading to the newest releases of WSO2 API Manager and WSO2 BAM.

“What was really essential to us was the integration between WSO2 API Manager and WSO2 BAM, and we are thrilled to continue advancing the system to support our company’s growth,” Chuck said. “WSO2 has truly helped us become a “connected enterprise,” bringing everything and everyone in our system together.”


Interested in similar content?