Code icon

Engineering

Reading progress

Collage of abstract characters and elements with SDK v2.0 badge in center
Collage of abstract characters and elements with SDK v2.0 badge in center

Introducing Huddle01 SDK v2.0: Better Scalability, Reliability & Performance

From infrastructure enhancements to multi-region cascading and improved client functionality, the Huddle01 SDK v2.0 is more reliable, scalable, and developer-friendly. Keep reading to learn how these advancements can empower you to build innovative real-time audio/video communication applications.

Author Image

Arush Kurundodi

Feb 1, 2024

Share on

Introducing Huddle01 SDK v2.0.

From infrastructure enhancements to multi-region cascading and improved client functionality, the Huddle01 engineering team has worked to make the SDK v2.0 more reliable, scalable, and developer-friendly. Keep reading to learn how these advancements can empower you to build innovative real-time audio/video communication applications.

Here are the main improvements the Huddle01 SDK v2 provides:
  • Global coverage

  • Higher scale

  • Smoother reconnection

  • Zero-downtime deployments

  • Improved developer experience

Now, let's dive into the details ↓

Infrastructure Improvements

  1. Transition to uWebSockets for Improved Performance & Reliability

    Previously, when using socket.io, we encountered noticeable lag and delays in WebSocket connection creation timings. The library struggled with reconnections and managing the states of the WebSocket connections. It often flushed the metadata during reconnection, especially on poor network performance. Although socket.io automatically switched to HTTP long polling in such cases, it never upgraded the connection back to WebSocket, resulting in increased latency and server load (as long polling is resource-intensive). We had limited control over reconnections, downgrades, and state management, which led us to explore other low-level WebSocket servers that allowed us to have full control over the entire lifecycle of the WebSocket.


    UWebsockets can handle at least 10 times the load of Socket.io.


    We decided to transition from socket.io to uWebSocket, a performant C++ web server that is highly regarded for its scalability, even by platforms like Discord. With uWebSocket and our in-house reconnection algorithm, we now have smooth transitions across networks. This has significantly improved our user experience, as reconnections have been flawless, and in the event of failures, uWebSocket provides access to connection metadata to aid in recovery.


    Now, the WebSocket connections are so robust that the session remains consistent even if the WebSocket server crashes, as it can easily reconnect using the stored connection metadata.


  2. Global Region Aware Distribution with Zero Downtime Upgrades

    The RTC Infrastructure has undergone significant changes to enhance its global distribution and scalability. It is now deployed across multiple geographical regions, ensuring optimal connectivity and performance for rooms.
    We have also implemented mechanisms for Zero Downtime Upgrades to the infrastructure. This allows for new performance and security updates to be pushed to the infrastructure without ever affecting the user's experience.

    This new architecture allows for seamless auto-scaling based on load, efficient handling of failures and recovery, and enables zero-downtime deployments. Additionally, we have implemented fast messaging capabilities using Protocol Buffers over gRPC, enabling efficient communication within the system.


  3. Multi Region Cascading

    Previously, Rooms were restricted to a single mediaserver, with the location of the mediaserver determined by the location of the first peer to join the meeting. This approach worked effectively when participants from the same region were present.

    However, it presented challenges when peers from distant geographical locations joined. In such instances, they would experience increased latencies and bandwidth consumption, which could adversely affect the quality of the meeting. To resolve this issue, a new solution was implemented.

    Introducing Multi-Region Cascading: This has enabled us to seamlessly cascade a meeting room across multiple media servers in various geographical locations on a large scale. With this algorithm, participants are intelligently connected to the media server that is geographically closest to them, guaranteeing unparalleled advantages such as significantly reduced latencies, superior media quality, and reduced bandwidth consumption.

    This not only helped us provide a better quality experience to our users, but also allowed us to horizontally scale our meetings. We can now support more peers in the same room by cascading the same room across multiple servers in different regions.

SDK Client Improvements

After our SDK v2 has been available to our community for the past 1.5 years, we have received a lot of feedback regarding improving the developer experience, ease of integration, and numerous feature requests. With Huddle01's SDK v2, our aim is to address this feedback and make improvements accordingly.

  • We performed a major internal code cleanup on the client-side SDKs, which involved eliminating the use of third party state management. In version 1, we relied on XState for this. Now, we utilise simple event listeners and use that to handle local states internally to ensure reactivity in the SDK.

  • We transitioned from using JSON to Protocol Buffers to reduce the size of message payloads for interactions between the client and server. This change also allowed us to maintain consistent schema and cross-compatibility across all current and upcoming clients like (Flutter on Dart) due to automatic type generation with Proto files.

  • Recording and live-streaming can now be initiated with a single API call.

  • We introduced Functions and Hooks to provide more precise control over media source selection. i.e. Introduced the concept of Remote & LocalPeer to cater to simpler developer experience while allowing developers to have granular control over each stream from every peer

  • We removed the Lobby concept in favour of a simpler and seamless joining flow.

  • AccessTokens for Peers were added to allow developers to have granular permission control. This enables developers to incorporate custom business logic and implement first-class authentication control using any server-side authentication method.

  • Custom Metadata is now available for the Room , individual Peers and their media streams, enabling more creative and custom use cases such as MetaVerse and Webinars.

There are several neat changes included in the SDK v2 Docs. Our main objective was to enhance the SDK's reliability, ease of integration, and scalability. We put great emphasis on making it more robust and capable of handling large-scale communication needs. At the same time, we wanted to ensure that the SDK remains flexible and adaptable to accommodate innovative and non-traditional use cases in Real Time Communication.

Build interesting applications with the Huddle01 v2 SDK and get featured on: https://docs.huddle01.com/docs/showcase

Start building with Huddle01 SDK v2.0 : https://docs.huddle01.com/

For developers who have already built on top of our v2 SDKs, here is the migration guide: https://docs.huddle01.com/docs/migration

We're also hosting an open AMA next week with our Lead Engineers to discuss the upgrades. Feel free to hop on and ask all your technical questions regarding the new SDK.

🗓 6th February, Tuesday

⏰ 9PM IST

📍 https://discord.gg/huddle01-890224574761926756?event=1202598104516534302