Firebase v/s REST APIs – A Developer’s Guide
Nowadays it seems like there is a service for every problem you have. The dilemma that existed a few years ago was to bring these services to more people. With the advent of mobile apps, it became possible to solve this problem. It is an undeniable fact that mobile apps have changed every aspect of our lives. Everything from buying groceries, ordering food, performing a bank transaction, communicating, or even traveling can now be done with an app. New apps continue to be made, and they significantly change the world. We live in a world where technology has the power to change social norms. Apps have never had more influence than they have today.
What is Firebase?
Firebase is Google’s mobile application development platform. It can power an application’s backend. The backend of an application includes data storage, user authentication, static hosting, and other functions. It can help you build mobile and web apps that scale from one user to even a million. Firebase can help you build, improve, and grow your app.
Advantages of Using Firebase:
- Cloud Functions – It can run the backend code in response to events triggered by HTTPS requests.
- ML Kit – It brings Google’s machine learning expertise to Android and iOS apps in a powerful, easy-to-use package. The ML Kit offers convenient APIs that help you use custom TensorFlow Lite models in your apps.
- Authentication – It provides easy-to-use SDKs, UI libraries, and backend services to authenticate your users. It supports authentication using passwords, phone numbers, and popular identity providers like Google, Facebook, etc.
- Real-time Database – It has a cloud-hosted NoSQL database that lets you sync between your users in real-time. The database is a big JSON object that developers can manage in real-time.
- Performance Monitoring – This feature helps developers gain insight into the performance data of their apps. It helps the developers understand where there is scope for performance improvement.
In summary, Firebase is
- Less time-consuming as it already is a ready-made solution
- Real-time solution for apps with real chats in it
- Pretty secure – as it is owned by the Big and Powerful Google
Disadvantages of Using Firebase:
- Data Migration – Since Firebase uses JSON, its storage format is entirely different from SQL. Thus, data migration will not be as easy as with a simple SQL database. As a result, developers will have to use safety conditions everywhere during migration.
- Reporting Tools – The reporting tools in NoSQL are not very good, but the tools in Firebase are far worse. Firebase’s tools do not even compare to a simple SQL database in terms of ease-of-use.
- Pricing – Its costs vary based on the data consumed and the number of users. For a limited 50 connections and 100 Mb of storage, and it costs around $25 a month. Once your app grows, you would be paying an amount that would just make it non economical to use Firebase.
- You Do Not Own Data – Your data hosted on Firebase servers, is not owned by you. It is also not possible to export your user data. Emails cannot be exported, and user accounts are not recoverable. It is not possible to export any data from within the dashboard. The only way to export email and password data is by contacting the Firebase team. This means you cannot migrate easily to an OnPrem version later.
- Not Widely Used – Most enterprises do not use Firebase as most apps expose developer API (Application Program Interface). This is not possible to do with Firebase. The data is hosted remotely, and the libraries leak memory. Hence, even remotely querying your database upon receiving API requests would be extremely slow. Overall too Firebase is not used by enterprises and hence may not be battle tested for the same.
- No Control on Downtime – There have been incidents in the past where the service has faced disruption. While that is possible for any service, in case of using Firebase you do not have control over the things to fix them. You may have to just wait.
This means Firebase may not be the right choice when you are thinking about scale. While Firebase may help you with faster time to market and save substantial cost for an MVP, there would be a point when you would have to forego Firebase once your company enters the territory of a recognized startup.
What are REST APIs:
REST is an acronym for Representational State Transfer Technology. Roy Fielding first presented this new approach to developing web projects and services. It is an interface between systems using HTTP to obtain data. Its function is to generate operations on that data in all possible formats such as XML and JSON. Today REST is the leading international authority in the fields of APIs and service app development. There are no applications or projects that do not use REST APIs for the creation of professional services. Even huge corporations like Facebook, Twitter, YouTube, etc. use REST and REST APIs to generate horizontal growth in their businesses. It is the most efficient, logical, and widespread industry standard in the creation of APIs.
Advantages of Using REST APIs:
- Separation of Client and Server – Its protocol separates the user interface from the server and data storage. The separation improves the portability of the interface to other types of platforms. It also allows different components of development to evolve independently.
- Visibility, Reliability, and Scalability – The development team can scale the application without much issue. They can migrate to other servers or make any changes in the database. The only requirement is that the data from each request must be sent correctly. Since the front and backend are on different servers, it becomes more flexible to work with these apps. The APIs can act as a standard gateway for other apps.
- Platform Independence – The REST API always adapts to the type of syntax or the platforms used. It can have PHP, Java, Python, or Node.js servers. Hence, it gives significant freedom when changing or testing new environments. The only requirement is that the responses to the requests should always take place in the language used for the information exchange.
Disadvantages of Using REST APIs:
- Architectural Constraints – Its design is bound by several structural constraints such as:
- Its use of a uniform interface
- Client-Server based infrastructure
- Dependence on caching
- Layered system architecture
- Transmission of code on demand
If your business goals are in line with this architecture, you will have no issues with REST. If that is not the case, then you should choose another schema.
- Learning Curve – The REST API design requires the backend to be built in totality. This would mean larger cost and time investment for you. Developers who do not understand its limits may not be able to maintain state within sessions.
These are the basics of Firebase and REST APIs. Firebase probably doesn’t offer every single tool and component required to make an app like super successful but it could provide a foundation to get started.Choosing between the two comes down to your requirements. If you want your app to have a real-time database, you should go with Firebase. If you require more efficient queries during development, you should pick REST APIs. You can also combine the two by having a Firebase database attached to your REST API.
At Mindbowser, we use either of the solutions depending on the context, longevity and requirements. Feel free to discuss with us about your requirements and we can advise you what suits best.