
Optimize multi-threaded Backend architecture and cloud infrastructure for music platforms.
Project Background and Technical Challenges: Online music streaming platforms face an extremely common yet extremely harsh challenge of the digital entertainment industry: Concurrency and multimedia data transmission bandwidth. In the early stages of startup, the platform's software system was designed in a static monolithic structure, using a single database to handle all tasks from user authentication, storing MP3 files, to recording music listening history. As daily active users (DAUs) surpassed hundreds of thousands of visits, especially during peak night hours, the old architecture quickly collapsed. Songs are constantly buffering, playlist loading time lasts more than 5 seconds, and the database system often falls into a Table Locks state due to having to receive millions of commands to record music listening history (Listening History) at the same time. User churn rates skyrocketed, directly threatening the survival of the project.
Architectural Solution: Microservices Decomposition and Database Diversification (Polyglot Persistence): Instead of looking for expensive physical hardware upgrades for a bottlenecked source code system, the engineering team decided to perform a comprehensive restructuring surgery, splitting the monolithic system into microservices (Microservices) independent. Tasks that require data integrity, transaction calculations and high security such as login authentication (Authentication), payment plan management, and user account information are completely rewritten in Java language with the powerful Spring Boot framework. These strictly structured data are securely stored in the PostgreSQL relational database management system to ensure consistency (ACID).
Meanwhile, the huge, unstructured data stream that continuously arises in real time (such as operation coordinates, second-by-second music listening history, and dynamic playlist suggestion algorithms) is extracted into a completely separate service. This service is built on the Node.js (Express) platform, which is extremely famous for its super-fast asynchronous processing capabilities (Asynchronous I/O). This huge amount of data is no longer crammed into PostgreSQL but is directed straight into MongoDB - a NoSQL database management system that specializes in handling unstructured data and has the ability to write data at super speed. This clear separation of responsibilities immediately completely relieves the burden on the core trading system, completely eliminating the phenomenon of server downtime.
Cloud Infrastructure Integration Leverage: The second turning point of the optimization campaign lies in the way high-format audio files (Lossless Audio) are stored and distributed. The traditional system of local file storage on servers is completely abolished. The entire treasure trove of millions of audio files is moved to Amazon S3 (Simple Storage Service) cloud storage - a solution with unlimited capacity and data durability up to 99.999999999%. To completely solve the problem of lag when listening to music, the system does not allow users to download files directly from the physical server at the original storage point, but integrates tightly with the Amazon CloudFront global content delivery network (CDN). Thanks to that, a song will be copied and saved in cache on hundreds of satellite servers distributed throughout geographical areas. When a user presses the "Play" button, the audio stream will be transmitted from the satellite server closest to them (Edge Location), radically reducing the physical distance of the network signal.
Results and Lessons Learned: After three months of restructuring efforts and uninterrupted service deployment, the online music platform recorded spectacular key performance indicators (KPIs). The average latency to respond to a song playback click plummeted by 40%, to almost instant (under 200 milliseconds). System error rate due to database overload (Database Connection Timeout) reduced by 98%. Most importantly, the new infrastructure architecture creates infinite horizontal scalability. Now, when the platform organizes exclusive album launch events of major artists that attract a surge of users, the automated monitoring system will automatically clone Node.js containers to absorb the traffic, and automatically shrink when the event ends to optimize cloud budget. This case study is a clear demonstration that: in modern software design, using the right technology, separating the right data structure and leveraging the power of cloud platform providers is much more important than just blindly enhancing the hardware server configuration.