Developing a better architecture
SiteSpirit’s initial prototype of its new media-library-as-a-service application—known as MediaSpirit (mediaspirit.io)—followed a relatively traditional architectural model. The app was built on top of open-source relational database and message queuing platforms, and ran on virtual servers hosted by a platform-as-a-service provider.
“The first version of MediaSpirit was a great step forward in terms of functionality, but it wasn’t as scalable, performant or cost-effective as we wanted it to be,” says Nijenhuis. “We had to pay for a relatively large virtual server to support peak workloads, but most of the time, we weren’t actually utilizing much of that capacity. When we did have multiple users on the system, the speed of searches with our relational database was quite slow—we were doing too many joins, and the queries could take ten seconds or more to complete.”
The SiteSpirit team decided to rethink the architecture completely, and rebuild it using new serverless technologies.
“We were intrigued by the serverless concept—the idea that your application doesn’t actually run at all until someone wants to use it,” explains Nijenhuis. “When IBM announced that Apache OpenWhisk serverless computing was going to be launched on IBM® Bluemix®, we dived straight in. We started using OpenWhisk when it was still in beta, and we immediately became huge fans.”
SiteSpirit has split its application up into a number of independent services—or in OpenWhisk terms, “actions”—that can be executed separately. When a user visits the MediaSpirit website, it triggers OpenWhisk to immediately allocate server resources and execute the relevant actions—for example, uploading, tagging, searching, cropping, resizing or downloading an image. When the execution has finished, OpenWhisk releases the resources that the action was using—so no code is running, no server is idling, and no costs are incurred unless users are online.
Equally, if a large number of users log on at the same time, OpenWhisk can simply scale up the server resources allocated to each action, and share the workload. The scalability is seamless, and ensures that all users enjoy a smooth, responsive online experience, regardless of how busy the site is.
“OpenWhisk gives us an easy, cost-effective way to handle peak demand and deliver a responsive user experience without worrying about how to scale,” says Nijenhuis.
SiteSpirit also redesigned the data layer by moving from a rigid, tabular relational model to a flat, schemaless JSON structure. It now uses IBM Cloudant® to store and manage all of MediaSpirit’s image tags and metadata, while the images themselves live in an object storage repository.
“The number-one feature that users want from an image library is a fast search capability,” says Nijenhuis. “Using a NoSQL database to flatten the data structure and eliminate joins gives a big performance boost to start with, and Cloudant’s full-text search is exceptionally good.”
He adds: “We also really appreciate Cloudant’s database-as-a-service approach. As a small development team, it’s important for us to be able to stand on the shoulders of giants—so when IBM can provide a fully managed database, it’s a great benefit. It frees us up to focus on what we’re good at, developing new application logic and better functionality for our users.”
SiteSpirit also appreciates the easy replication that Cloudant provides. Whenever the team needs to onboard a new client and set up a new image repository in MediaSpirit, they can simply replicate their master database template and start populating it with the client’s data within minutes.
Over the course of the development of the new version of MediaSpirit, SiteSpirit’s developers have remained in close contact with IBM OpenWhisk and Cloudant support teams.
Nijenhuis comments: “We’re doing a presentation soon at an IBM conference, and the title is ‘A Love Story’. That’s how we feel about our relationship. We used to see IBM as a big company that was hard to reach. Now it’s really easy to work with them: there’s a great community, and they’re helping us flourish with the apps we want to build.”
Putting performance in focus
With the new architecture in place, MediaSpirit’s users can find the perfect image for their campaigns and collateral in seconds—and use unique functionalities such as Focus Point to crop, resize and output media in exactly the right size, shape and format for each deliverable that they want to create.
Nijenhuis comments: “Even our earliest prototype made it much faster to find, edit and download images, compared to browsing through folders on a file server. But the latest version has completely changed the game. Cloudant is amazingly quick at full-text searches, and OpenWhisk keeps the performance consistently fast, regardless of the number of users. Searches run at least ten times faster, so we’re seeing sub-second response times even when the system is under heavy load.”
Equally important, the new version of MediaSpirit can scale cost-effectively to meet the demands of many concurrent users, without incurring large overheads when the service is not active. By spinning up new containers when—and only when—user demand increases, the serverless architecture keeps costs to a minimum.
“In the past, we sometimes had months when our hosting fees were eight times higher than they are today,” recalls Nijenhuis. “Looking at the average monthly fees, OpenWhisk has reduced our hosting costs by 90 percent.”
As a result, SiteSpirit is now ready to roll out MediaSpirit to a wider group of users without worrying about either costs or performance. The service is currently in private beta with the company’s current customers, but it will soon will be launched as a more public service.
Nijenhuis concludes: “We’re sure that many other companies will see MediaSpirit as an attractive prospect. Access to a fast, lightweight, cost-effective cloud image library could benefit companies in any industry that need to manage large numbers of photos, not just real estate and travel agents. And with IBM on our side, we’re very confident that we can deliver on our promises.”