How to Use OpenShift as a Mobile Backend (MBaaS)

OpenShift as a Mobile Backend as a Service

Are you in the process of building a mobile app or have created one in which you require some information or data to be stored off device? Do you need a server-side component to store stats, high scores, or maybe even location-based information? Perhaps you have users who need to interact with each other. Certainly there are situations in which you can have applications that can be self-contained (the calculator app probably doesn’t store anything on the server) but most modern apps are not going to be like that. When you’re exchanging a lot of data it makes life a lot easier to take advantage of what’s known as a Mobile Backend as a Service (MBaaS).

There are multiple services that not only help solve these problems but also auto scale based on load. The one I’ve been playing around with recently is Red Hat’s OpenShift platform. I think the service is interesting since it wasn’t designed specifically to be a MBaaS, but has this concept of quickstarts and cartridges that let it become extendable and take on new functionality.

What to look for in a Backend:

Storage of Custom Objects

My mobile apps are iOS and due to the nature of Objective-C, you typically have objects that represent some type of information. So relational DBs, while usable, are not ideal. Mongo makes sense for storage but for a Mobile Backend you want the process of storing and retrieving to be easy.

That’s why I like the MongoLabs integration in OpenShift. It provides an API layer over MongoDB that makes it easy to communicate from my mobile device without having to create my own custom APIs.

Spatial/Geo Support

The apps I see that take the best advantage of a MBaaS usually have a location-based component. It’s useful to perform searches on objects near a particular location. With MongoDB and the MongoLabs API this becomes very easy to implement.

 POST
 https://api.mongolab.com/api/1/databases/mbaas/geomail
 
  data: { "email" : "kunal@sendgrid.com",
          "location" : { "lat" : 40, "long" : 73 } }
 
       GET
       https://api.mongolab.com/api/1/databases/mbaas/geomail?q={"location":{"$near":{"lat":40,"long":73}}}
 

Strong 3rd Party service integration

The other aspect of what makes Redhat an interesting choice is the abundance of quick starts / cartridges to quickly use 3rd party APIs and integrate their services quickly into your backend. With a quick RHC command line script I can quickly set up very useful applications without having to worry about environment or dependency issues.

Real Time Push Notifications

Users expect mobile applications to be always-on, which means you need your MBaaS to be real-time. OpenShift has a Pusher quickstart and a PubNub quickstart, too.

Message Queues

For the stuff that can’t be processed immediately, you need to put it in the queue. There’s an Iron.io quickstart that puts your app in line.

Communication

Yes, I often want my apps to send an email, a text message, or even make a phone call. Those are easy with the SendGrid quickstart for email and Twilio quickstart for SMS/Voice.

The extensible nature of OpenShift makes it simultaneously a blank slate server platform and a fully-featured MBaaS. Because it’s not tuned to any specific language, I can run a large set of technologies on my backend. The plug-and-play cartridge system makes it easy. You can even make your own cartridges.

The next time you’re building a mobile app, it will probably need a backend. Consider trying out OpenShift and let me know what you think.

More from this author