For mobile app developers, delivering real-time updates and seamless user experience are crucial. However, achieving efficient real-time data synchronization between client devices and servers can be challenging. In this blog post, we'll explore how combining LiveQueries in SashiDo with a message broker like Redis can significantly enhance the real-time performance of your mobile apps.
Understanding LiveQueries
LiveQueries is a powerful feature offered by Parse, the open-source mobile app development framework that SashiDo is built on top of. It enables you to subscribe to real-time updates on data changes in the Parse server. Unlike traditional methods that require periodic polling or manual refreshing, LiveQueries automatically pushes updates to connected clients in real-time. This ensures users receive the latest information without delay, resulting in a smooth and responsive user experience.
Live Queries are integrated and automated in SashiDo’s Dashboard and you can access and manipulate them easier than ever. You can enable SashiDo’s Build-in Live Queries with just a click and start building scalable real-time apps including features such as activity and notification feeds, chats, charts, maps, geo-tracking, multiplayer gaming, and more.
Limitations while using LiveQueries
Parse's default design doesn't allow Live Queries to be communicated between different instances without a message broker like Redis. This limitation affects the proper functioning of Live Queries across multiple Engines(e.g. servers), including in High Availability setups. Here are some issues that you may encounter:
- Lack of Scalability: LiveQueries in Parse are not designed to communicate seamlessly between different instances. This limitation hampers the scalability of real-time updates across multiple engines or in high-availability setups. As a result, you may face challenges when attempting to scale your app to handle increased traffic and user demand.
- Lack of Data Synchronization: LiveQueries rely on direct communication between the Parse Server and client devices. This approach can result in a lack of data synchronization, especially in scenarios where multiple clients are simultaneously subscribing to the same data updates. Using a message broker like Redis is a very effective way to solve the problem. Implementing alternative solutions if you don't have enough experience is not recommended. Failing the setup might result in increased server load and the client devices may receive redundant or delayed updates, impacting the real-time performance of the app.
- Inefficient Server Refreshing: In the absence of a message broker, client devices can’t refresh the server to fetch the latest updates. If you attempt to implement some alternative manual approach this could lead to increased network traffic as devices continuously send requests to check for updates. As a consequence, both the server and client devices may experience unnecessary network congestion, resulting in slower response times and a less optimal user experience.
- Inconsistent Data Delivery: Without a message broker to efficiently distribute updates, data delivery can not be consistent. For example, some client devices may receive updates faster than others, leading to a lack of synchronization across all connected devices. Inconsistent data delivery can confuse users, disrupt collaborative features, and compromise the overall reliability of real-time updates in the app. Thus implementing experimental or manual approaches for the purpose is not recommended.
- Redundant Code and Complex Logic: You may be required to write complex code and implement custom logic to handle real-time updates without a message broker. This can add unnecessary complexity to the app's codebase, making it harder to maintain and debug. Additionally, the absence of a message broker may result in redundant code across different parts of the application, increasing development efforts and potentially introducing bugs.
What can we do about it?
However, two viable options can address the above issues while using LiveQueries:
- Scaling to a single powerful engine: You can scale your app to a single engine, opting for a more robust option such as the Performance type. Testing this setup is essential to determine if it meets the app's requirements and performs optimally. While this solution reduces redundancy by relying on a single engine, it ensures the proper functionality of LiveQueries.
- Adding Redis as a message broker: To overcome the limitation of LiveQueries, you can integrate a Redis message broker. Redis acts as an intermediary, evenly distributing messages between multiple engines in horizontally scaled setups. This ensures that Live Queries function smoothly across all instances. Upon request, SashiDo’s engineers can initiate a Redis instance for the application, offering a reliable solution.
Redis Instance Options
You have several Redis instance options to choose from based on your app's needs and growth stage. These include:
- Redis Nano: With 50MB of RAM, this is the smallest instance suitable for test apps or projects in the development stage. The pricing for Redis Nano is $12/month.
- Redis Micro: Offering 100MB of RAM, this instance is ideal for newly launched or small projects. The pricing for Redis Micro is $24/month.
- Redis Small: With 250MB of RAM, this instance suits growing applications in production. The pricing for Redis Small is $48/month.
Additional more powerful instances are available upon request for applications that require higher performance to handle increased traffic.
Considerations and Charges
It's important to note that the Redis service offered by Sashido is set up exclusively per application and incurs an additional recurring charge on the monthly subscription of the customer’s account. These charges are not removed upon app deletion. To stop using and paying for the Redis service, you must submit an official request to Sashido's support system.
Conclusion
By combining LiveQueries in Parse with a Redis message broker, you can significantly enhance the real-time performance of your mobile applications. Whether scaling to a single powerful engine or utilizing Redis to distribute messages between multiple instances, these solutions ensure seamless real-time updates and a responsive user experience. While awaiting the official release of the Redis Feature in the Dashboard, you can request the Redis service from Sashido's support system and choose from various instances based on your specific needs.
Happy Coding :)