Thep Urai - Fotolia

Tip

Cache networks for better mobile application performance

Architects find they can improve mobile application performance by leveraging caching networks and new data synchronization protocols.

Enterprise architects are finding they can improve mobile application performance through new approaches to crafting their SOA infrastructure and application development tooling. One approach is to architect SOA infrastructure to leverage  new caching services that support a larger percentage of Web application related data. Another approach is to craft SOA infrastructure to support more efficient protocols for data synchronization.

"This was a good decision for us, and made it a lot easier to develop performance applications," said Eric Marston, CTO of DailyLook.com. The company provides an online shopping experience that features daily fashion inspiration curated by professional stylists. It re-engineered its enterprise architecture and application development process with a comprehensive caching strategy to dramatically increase mobile app performance and reduce the load on its back-end infrastructure.

The company had previously invested considerable resources in a strong middleware tier so that Web and mobile applications could interface to the back end through common middleware components. This allowed code reuse and improved application development, said Marston. But considerably more work was required to think about promoting better application cache-ability.

Mobile is mission critical for consumer engagement

Improving the mobile application integration was critical for DailyLook. About 90% of the company's traffic comes from users of its native mobile app. Marston evaluated a number of content distribution network, or CDN, services, but found that most of them were only optimized for static content, he said. By leveraging the Instart Logic Software Defined Application Delivery Service, DailyLook was also able to accelerate much of its JSON messaging between DailyLook's back-end infrastructure and mobile clients.

The Web application existed before the mobile app, so DailyLook refactored the Web application to better leverage this new middleware tier. This has made it easier to work with the Instart platform. Marston recommends that organizations consider organizing their middleware tier to cache JSON data objects. This makes it possible to stage data at the edge along with everything else.

Planning required for best caching

In the last year or two there's been tremendous innovation on the front end to make building real-time apps like these possible.
Slava Akhmechetfounder, ReThinkDB

"This has reduced our database loads, Web server loads, and the application responds much quicker," Marston said. This can be a challenge for many organizations, but is mission-critical for enterprises in the retail space. The process involved figuring out how to segment and pull the data out, so that anything personalized or specific to individuals was separated from the more static product data. In some cases, this meant two smaller calls were made to the DailyLook infrastructure, but this also meant that more data could be staged closer to the users.

Now users are able to receive updates from the edge servers in about 30 milliseconds, rather than the previous 500 milliseconds. Overall, this strategy has allowed DailyLook to offload about 70% of its total data requests to the edge servers. Also a good practice is developing efficient caching rules that work for the business, said Marston. Data relating to popular new style requests can be cached for several hours or even days, but other data is far more transitory.

Marston recommends organizations encourage developers to consider better caching strategies during code reviews. Putting this into the review process helps ensure new applications are as optimal as possible.

Another good practice is to consider caching strategies as part of the middleware architecture. DailyLook was about half-way through deploying its middleware tier before realizing it could be more efficient with a good caching strategy. Marston also recommends using a technology like JSON that is easy to cache. JSON is not as easy to use as HTML caching, but when used appropriately JSON can help reduce the load on database servers.

Consider new protocols

Other mobile experts are encouraging developers to think about data synchronization as a more efficient alternative to caching. "The real value is when the data synchronization system is lined up with all the other parts of the application stack," said Matt DeBergalis, co-founder of Meteor Development Group, which makes the Meteor open source JavaScript development framework.

For example, the Meteor development platform supports direct integration with the DDP protocol that uses WebSockets as a more efficient protocol than REST or JSON for many use cases. In Meteor, when the server updates information, the screen on the mobile device automatically updates.  The developer does not have to write special code to take advantage of automated synchronization. The end result is that data is cached on the mobile device rather than in the middle.

The HTTP protocol, which is traditionally used for JSON and REST, is oriented toward retrieving documents from the Web, but live updating apps need a way to send updates without the client asking. More performant apps can leverage emerging new protocols like WebSockets, which are capable of automatically sending data to the client without a specific request. But the basic WebSockets protocol is low-level, which makes it difficult to efficiently use in applications, said DeBergalis.

Design for synchronization

The biggest challenge with building these kinds of apps is in the data layer on the back end. All databases to date have been designed to respond to queries, not to push data out to the back end when something changes, said Slava Akhmechet, founder of ReThinkDB, an open source database synchronization tool. Back-end engineers are forced to build complex infrastructures and sophisticated custom code to work around these limitations in the data layer. Much of this work requires custom code on the front end, which further complicates the development and deployment process.

Sophisticated teams with big budgets and lots of time can implement this functionality on top of existing databases using a combination of traditional features such as views, triggers and third-party queuing systems like RabbitMQ. That can work quite well, but it is very challenging and expensive to build because this approach is very error-prone and takes a lot of development resources, noted Akhmechet.

"In the last year or two, there's been tremendous innovation on the front end to make building real-time apps like these possible," said Akhmechet. Frameworks like Meteor, Angular and React treat real-time use cases as first-class citizens, and all major Web browsers support technologies like WebSockets and long-lived HTTP connections to make pushing data to the browser in real time fast and easy. These tools promise a viable alternative to traditional caching networks for creating the next generation of mobile apps, he said.

Next Steps

Learn about cache computing

How do content distribution networks stack up to cloud services?

Read about the importance of mobile application performance

4 critical API caching practices all developers should know

Dig Deeper on Application development and design

Software Quality
Cloud Computing
TheServerSide.com
Close