elasticsearchmongodb

Building a Mobile App? Here’s How to Make the Most of Your Database

By March 27, 2018 August 18th, 2022 No Comments

These days, it seems like everyone and their dog has a mobile app. With good reason, too: “people are spending an average of 3:23 per day in apps, and only 50 minutes on the mobile web.” Users prefer to interact with companies through their apps, especially on mobile, where web browsing isn’t quite as versatile as desktop. With that in mind, it makes sense that so many businesses have thrown their hat in the ring.

With great apps come great responsibilities. Once people start picking up your app, you have to dedicate resources to keep that app up and running well to keep your users happy. Apps have the potential to explode in popularity and flood your servers with users. That’s a great problem to have. However, if you’re not prepared for that, it can quickly turn into a nightmare of lags, unhappy users, and a stressed out IT department. Sometimes usage spikes will happen during a certain time of year. Here are some quick examples: If you’re in retail, you may have to deal with spikes around the holidays. If you’re a business with students as the primary audience, you may experience usage spikes around back to school time. If you’re MapMyFitness, you have to prepare for usage spikes with New Year’s resolutions. What’s more, all those users add a lot of data to your database. If it’s not built correctly from the start, your database may not be able to perform well and provide quick responses back to queries from the app. It also may not be able to scale for growth in usage to handle all the new users that your fabulous app will gain.

A traditional relational database is often ill-equipped to handle the varied structure of the different data inputs or the potential sudden and drastic growth in mobile users and in data. The good news is that there are other databases and data stores that can empower your app and handle these new challenges. We’ll discuss which alternatives are at your disposal and how they can benefit your application performance and your database management.

MongoDB

Mobile apps have unique database needs and requirements. They need to be able to scale horizontally, sometimes into the millions of users. Often, the data is either polymorphic, unstructured, or semi-structured, and developers need a database that can work with that kind of data. With many developers working in an Agile framework, app development needs to be flexible enough to be implemented iteratively. That way, you speed time to market and can add cool new features that can keep you a couple steps ahead of the competition.

Relational databases like MySQL are good at a lot of things, but handling the above-listed mobile needs are not generally their strength. That’s where non-relational (or NoSQL) databases—and MongoDB in particular—come in to play. As a non-relational document store database, MongoDB can scale easily and seamlessly. It can handle a wide variety of data, in different formats, from different sources. MongoDB has the flexibility of being somewhat ‘schemaless’, unlike relational databases such as Oracle, which are normally modeled to have strict schemas. (This is something developers often chafe at.) With NoSQL databases like MongoDB, developers can create applications using simple and wonderful JSON-style document structure. It can update and iterate without having to be taken offline. It’s a nice fit for many mobile applications, depending on the specific application and its usage patterns, of course. (That’s where having database consultations are so important.)

Additionally, MongoDB has been around for a long time, so it’s a widely used tool with a solid support base. Queries are written in javascript which is similar enough to other languages that developers use and it’s even somewhat similar to SQL, with slightly different syntax. Therefore, it’s usually not too challenging to acclimate to using MongoDB. Best of all, it’s open source. So if you’re building a database for a mobile app, MongoDB is a great option.

Elasticsearch

Elasticsearch is an additional data store that can be used as an add-on tool compatible with MongoDB. Its original use was that of a search engine. Elasticsearch takes any data placed inside of it and indexes it, so that it can be very quickly and easily searched. The strength of Elasticsearch is that it handles full text, fuzzy text, word completion, and also geo queries very, very fast. While there are other tools, such as Solr out there that can do at least that much, Elasticsearch has gone a step further by adding additional functionality and abilities. It doesn’t just make data searchable, it has the ability to use other components of the Elastic Stack to provide business intelligence levels of analysis to data.

With Elasticsearch, you can write advanced queries for your search. Beyond that, you can write predetermined search queries to do things like identify traffic from IPs from a specific country. It can do grouping, summation, averages, and more. Adding Kibana allows you visualize your Elasticsearch data with time series data, geodata, and more. For those who are really looking to maximize their database’s value, Elasticsearch with Kibana is worth considering.

Redis

Redis is another add-on that functions effectively as a nitro boost in the form of a caching tool. You input the data for common queries from the database into Redis, and then when those queries are being made, they hit Redis rather than the database. That way, Redis can return the results faster than the database would because it’s not searching the whole dataset for an answer. It sounds simple, but it can have a dramatic impact on how quickly you return results. (Check out our blog on the top 5 use cases for Redis for more information.)

DBaaS

Finally, for those who don’t feel like they have the resources for (or would rather not bother with) maintaining app databases, there is help. It’s called Database as a Service (DBaaS) and this type of outsourced database management solution can handle the whole process for you. A quality DBaaS provider can help architect your database to  get the most bang for your buck, help you set it up, house and maintain it, and offer 24/7, 365-days-a-year support and access with expert-level industry knowledge. In other words, they can take the burden of running a database—even one built on MongoDB for mobile applications—off of your shoulders so your developers can focus on creating amazing apps with new features to keep you one step ahead of the competition.

Interested in DBaaS? Contact us and we’ll discuss which databases are right for your app.