Перейти к содержимому

На чем написан spotify

  • автор:

What Programming Language is Spotify Written In?

Spotify Programming Language

Spotify has been a revolution in the music industry. It is a freemium service, and it is the provider of protected content from record labels. The basic features are free with the advertisement, but the paid version has better streaming quality and music download option. It is available for every device users including social media users and PlayStation users. There are robust search features for the convenience of the users, and currently, the platform has over 170 million users. There are multiple programming languages used in the development of this revolutionary platform which are mentioned below.

Programming Languages Used For Spotify –

According to the Wikipedia, the primary language behind Spotify development is Python. Among other significant languages used are Java, C++, and C. It is compatible with Android, iOS, Windows, Linux, and macOS.

But according to Andreas Blixt who is a 5-year employee of Spotify, the main language used is C++ and not Python. One may take it with a pinch of salt because C++ has become less convenient for the developers while Python is the language where most of the developments are taking place. He has also mentioned that C++ is at the core but due to the expansion of Spotify from its origin, different modules are created. These new modules are implemented in different languages for better development. These modules could have also been created in C++. Furthermore, the scope for using different programming languages has opened up the scope for more clients to work with the platform seamlessly. The use of JSON for passing data has become easy.

Interface – Apart from the programming language, it is using Chromium Embedded Framework. The views are written in the trio combination of HTML, CSS, and JavaScript. The interface layer called Cosmos is a perfect bridge between C++ and JavaScript and hence, interacting with different views in no more a trouble for the developers. On top of that, there is a layer of PHP that mainly executes the logging in and some apps on different domains. The rest of the part is JavaScript as far as the overall interface is concerned. JavaScript uses a specialized C++ service to ace to the backend.

Coming to the apps, you are aware of the fact that Spotify has so many different apps for different platforms. iOS app must be built in Objective-C, Android app must be built in Android, Growl for Mac OS X, NSIS for Windows, and likewise. The front end of the web application is said to have Ruby on Rails along with HTML, JavaScript, and CSS. Other the other programming languages used to build several components belonging to the third-party, there has been a mention of Boost, Expat, Zlib, and various other library languages.

Breaking Down The Different Components –

You can broadly divide Spotify into multiple components quite easily. There are desktop application component, mobile application component, web development component and the core components. Furthermore, you can take different accessories as another component, and these accessories are the ones that are primarily responsible for the use of so many different languages to create the entire platform. The core component is generally written in a language is the independent of the operating system. This helps the core component to stay intact, and the rest of the components can change and get customized as per the operating system used. Coming to the core part, there are a lot of opinions out, and it is safe to assume that it has been a combination of C++ and Python without giving anyone the higher preference.

Desktop Component – The desktop component has been written in C++ for most of the part, and that is why C++ has been mentioned in the documentation. Along with C++, JavaScript is also used for some of the web related components. For the Mac OS X users, Objective-C and even Objective-C++ have been used. The use of JavaScript for the native desktop app has been surprising to many. But Spotify uses Chromium embedded framework due to which the web components had to be developed in JavaScript for flexibility and scalability. Currently, Spotify does not allow third-party plugins which were previously there. This has more to do with the security purposes, and Spotify has bought a few plugins that were popular and embedded them directly into the platform.

Web Component – The web component has a little bit of everything. HTML 5, CSS, JavaScript are a common combination. There are no usual frameworks used, but a lot of Java and Ruby on Rails has been implemented for certain functional components. Apart from the web components, there are apps made for different platforms, and different languages are used accordingly for app development.

If you are looking forward to making such a platform, you have to go through the documentation to understand the different components and find interlinkable programming languages so that you can make different components in the best possible way without any compatibility issues.

На чем построен Spotify?

Какие технологии реально используются в Spotify. Где-то видел их в перечне использующих Python/Django, но builtwith показывает, что там PHP есть, а Python — нет.

  • Вопрос задан более трёх лет назад
  • 340 просмотров
  • Facebook
  • Вконтакте
  • Twitter

DevMan

  • Facebook
  • Вконтакте
  • Twitter

dimonchik2013

«что внутри» — он определяет по внешним признакам

для домашних страничек это катит, для проектов с баблом и командами — нет

System Design of Spotify

Learn Algorithms and become a National Programmer

In this article, we have explained the System Design of Spotify, a leading audio streaming platform in depth.

Contents

  1. Introduction
  2. Spotify Requirements
  3. Software Architectures
  4. System Design of Spotify
  5. Conclusion

1. Introduction

This article covers how apps like Spotify are designed to scale to large userbases.

Section 2 defines the requirements Spotify would need to fulfill for its userbase.

Section 3 discusses modern day architectures to implement large scale applications. We discuss two common architectures, monolithic and microservices.

Section 4 will provide an overview of the implementation of Spotify using its current techstack, building off concepts introduced in sections 2 and 3.

2. Spotify Requirements

Spotify is a large application, but it’s core functionality is to be an MP3 player that has access to one of the largest curated libraries of music and podcasts. This means it must be highly available in an international setting for millions of users.

Spotify needs to fulfill the following user requirements:

  • Account creation and AuthN/Z (Authentication and Authorization)
  • Audio processing
  • Recommendations
  • Fast searching
  • Low latency Streaming

For system requirements, Spotify must expect to handle:

  • Billions of API requests internationally
  • Store several hundred terrabytes of +100 million audio tracks.
  • Store several petabytes of metadata from +500 million users.

For data alone, Spotify needs to store both user data and data related to business, and this can be an infinitely increasing amount, with current data estimates around 5 petabytes.

3. Software Architectures

A software architecture refers to the blueprint/approach used to build software. Different architectures rely on different standards for building, integrating, and deploying components. There are two common architectures, Monolithic Architectures and Microservices Architectures, with microservices being the most recent architecture.

Monolithic

This is the industry standard of software development, where software is designed to be a single executable unit. This architecture is ideal for applications where requirements are fixed.

In a monolithic architecture, we divide an application into layers, with each layer providing specific functionality:

  • Presentation Layer: This layer implements the application UI elements and client-side API requests. It is what the client sees and interacts with.
  • Controller Layer: All software integrations through HTTP or other communication methods happen here.
  • Service Layer: The business logic of the application is present in this layer.
  • Database Access Layer: All the database accesses, including both SQL and NoSQL, of the applications, happens in this layer.

We often group layers together, with the Presentation Layer being called the frontend and Controller, Service, and Data Access Layer being grouped into the backend*. This simplifies software as communication between two parties. Any application can be described as a frontend (client) talking to a backend (server).

Dividing applications into these layers led to design patterns like MVC, MVVC, MVP, as well as frameworks that implement them like Spring for Java, .NET for C#, Qt for C++, Django for Python, and Node.js for JavaScript.

Microservices

Microservices builds off monolithic architectures. Instead of defining software as a single executable unit, it divides software into multiple executable units that interop with one another. Rather than having one complex client and one complex server communicating with one another, microservices split clients and servers into smaller units, with many simple clients communicating with many simple servers.

In even simpler terms, microservices splits a large application into many small applications.

The tradeoff between the two is summarized below:

  • Monolithic Architecture: Complex Services, Simple Relationships. Better for apps with Fixed Requirements (like a Calculator)
  • Microservices Architectures: Simple Services, Complex Relationships. Better for apps with Variable/Scaling Requirements (like a Social Media application)

Microservices borrows the exact same design patterns and layer methodology as Monolithic architectures, it only implements them with different tools.

Microservices works by integrating the following units:

  • Frontend
  • Backend
    • Content Delivery Network
    • Elastic Load Balancer
    • API Gateway
    • Circuit Breaker
    • Cache
    • Service Client
    • Streaming Pipeline
    • Services
    • Databases

    system_microservices

    Frontend

    The frontend is the graphical UI of an application or site that the client interacts with. Webpage frontends have the option being prerendered on a server and sent to a browser (server-side rendering aka SSR) or rendered directly in a brower (client-side rendering aka CSR). Application frontends are usually downloaded (as seen with Desktop and Mobile applications). CSR is more commonplace as UI components can be dynamically rendered and updated with lower latencies. Many frontend UI frameworks exist with many being in JS, but CSR can also be done through other langauges like C#, C++, Java, and more using Web Assembly.

    Backend

    This is the main application, which handles integrations and APIs with a Controller Layer, business logic with a Service Layer, and data storage and access with a Data Access Layer.

    Third party applications/libraries are often used to implement the components in each layer.

    Content Delivery Networks (Service Layer)

    A CDN or Content Delivery Network is used to solve latency issues when a client loads requested content on a device. A CDN stores static files to be quickly delivered to clients. It is placed on the network edge for services that prioritize delivering content to users.

    Load Balancers (Controller Layer)

    A load balancer is a specialized server optimized for routing that quickly distributes incoming requests across multiple targets. It is meant to evenly distribute requests across a network’s nodes to reduce performance issues. Load balancers can process millions of requests and usually redirects requests to one of many secure API gateways.

    API Gateways (Controller Layer)

    An API gateway is a server combined with several dynamic route filters that can filter and send batch requests to a specific microservice or service client. It reduces the number of round trips for data to make between services and can also handle functionality such as user authentication and SSL termination (where secure HTTPS connections are downgraded to HTTP connections for faster communication). An API gateway can also handle the same role as a load balancer, but API gateways handle fewer requests at a time versus a dedicated load balancer. For example, load balancers can route up to a million requests per second, while API gateways can only handle up to 10,000 requests per second. Large applications will have multiple API gateways that a load balancer can route to, and API gateways can be used to organize requests, such as requests from mobile devices, desktop devices, and browsers.

    Circuit Breakers (Controller Layer)

    A circuit breaker is a design pattern where the problems caused by latency from interservice communication can be avoided by switching to backup services in case a primary service fails. Hysterix is a Java library that adds fault and latency tolerance to microservices, acting as a circuit breaker. This is especially useful when using 3rd party microservices, as Hysterix can isolate endpoints and open ports to fallback services.

    Service Clients (Controller Layer)

    After data is sent from the API gateway and passes through a circuit breaker, it is received by a service client. A service client is a reverse-proxy HTTP server used as a microservice that allows other microservices to communicate with the API gateway.

    Caches (Service Layer/Data Access Layer)

    A cache is used to speed up responses when querying databases and warehouses, as the service client will first search the cache for the result of a recent response before posting an event on a streaming pipeline. The cache can be implemented with Memcached or Redis.

    Streaming Pipeline (Service Layer)

    A streaming pipeline is a piece of software that allows services to communicate with one another and process items in transit.

    Services are usually hosted with their own IP addresses and endpoints. Using a REST API can enable services to communicate with one another, but it becomes too coupled as every service must have the address to every other service it wants to talk to. Pipelines are a design pattern that allow services to talk to one another without storing information about the sender like an address. Instead a pipeline is a public inbox, where all services can check and see if a message or task exists for them. The pipeline itself is referred to as a message broker.

    Streaming pipelines can define the behavior of the message broker as either message- driven architecture or event-driven architecture. Message-driven architectures address a task for a select service to respond too, but any service can view it. Event-driven architectures simply post a task with no address and lets every service that views it decide whether to respond or not. Pipelines function off a publisher-subscriber model, where a service publishes messages or events to the pipeline, and other services can subscribe to the pipeline to see incoming messages and events.

    Both Apache Kafka and RabbitMQ are streaming pipelines, but since Spotify relies on a lot of real-time processing and a high amount throughput for its search and recommendation engine, Kafka is the smarter choice to use as a streaming pipeline due to its event-based architecture.

    Services (Any Layer)

    Services are independent instances of an application, which can be from third parties or developed in-house. Using containerization, we can host these running applications on multiple machines, then use a streaming pipeline to allow them to talk to each other.

    Pairing services and a streaming pipeline create the core part of the microservices architecture.

    Databases (Data Access Layer)

    A database is an application that can store and retrieve data. This software can be treated like any other service and is usually hosted on a separate server from the rest of the backend.

    4. System Design of Spotify

    Microservices is an architecture that is easy to scale and incrementally update over time. Because Spotify consistently faces changing user, system, and business requirements as user bases and monetization practices grow over time, microservices is the ideal architecture for it.

    Spotify implements microservices using the following tech stack. Below we’ll cover what each tool is used for and how they all integrate.

    Spotify uses the following technologies for its core application:

    Java — General Development Language

    Spotify is language agnostic, but a large portion of its codebase is in Java. The reasons why this is the best option may vary, from improved tooling, better frameworks, libraries, and documentation, object-oriented nature, lower staffing requirements. Spotify can just as easily be coded in other languages as well.

    NGINX — Elastic Load Balancer + API Gateway + Service Client

    NGINX is an open-source webserver that can be configured to be a load balancer, API gateway, and or service client. A load balancer, API gateway, and service clients are all just servers optimized for different properties (speed, security, and load). NGINX provides these optimizations and the server itself with prebuilt versions in a NGINX Plus subscription. The open-source nature means Spotify can modify and use the server in an enterprise without worrying about usage fees in the future.

    Hysterix — Java-based Circuit Breaker Library

    Not explicitly stated to be used by Spotify but can be used to reduce failures and improve fault tolerance in any microservices architecture. If a different language was used, then a different library could be used.

    PostgreSQL — SQL DB for storing user billing/subscription data

    This is another Open-Source RDBMS, meaning the software can be custom modified to fit Spotify’s needs without needing to worry about subscriptions. It might not be a better option to other open-source RDBMS like MariaDB and MySQL but was simply a choice during planning.

    Bootstrap — CSS Framework for Frontend Webpage

    While plain CSS can be used to style a frontend, Bootstrap provides many prestyled HTML components that can be used to build a UI with. Options like a JS Framework like React, Vue, and Angular could have also been used or a templating language like JavaFX.

    Amazon S3 — Static File Storage storing licensed Spotify songs.

    Spotify could purchase hundreds of hard drives to store the music it uses or outsource the hard work of setting up remote storage to Amazon and use their remote storage solution S3. S3 might be a good option due to its high availability and high fault tolerance when compared to other providers like Google Cloud and Azure.

    Amazon CloudFront — CDN Provider for making S3 highly available in multiple regions (helps Spotify scale its services internationally).

    If S3 can handle storage, CloudFront is a supporting tool to handle distribution of static content stored in S3 across the world. Now the Spotify app can access stored songs from any international client on its own private CDN hosted by CloudFront.

    Kafka — Event-Driven Streaming Pipeline for fast microservice routing

    Kafka is a very popular open-source streaming pipeline. Compared to options like REST or RabbitMQ, Kafka can handle millions of requests per second (compared to 10000 with Rabbit MQ) and has a Java SDK.

    Cassandra — Fast Distributed NoSQL DB for storing user data

    Apache Cassandra is an open-source distributed NoSQL DB that can be scaled on many remote servers. It allows Spotify to manage scaling datasets such as user metadata with ease. It’s open-source nature also reduces costs, as options like Redis and MongoDB may not scale as easily or cost more to use in enterprise.

    Hadoop — Distributed File System and Batch Computing of Historical Data

    Apache Hadoop is an open-source set of tools for batch processing historical data and large-scale distributed file storage. This historical data can allow Spotify to analyze large amounts of metadata. It also has the benefits of being open source making the storage of business data less dependent on cloud providers.

    Google Big Query — Cloud Based Data Warehouse for system analytics

    Spotify outsources analysis of some of its data to Big Query. Big Query is a data warehouse with ML features for generating analytics and defining business requirements. Spotify might store user data here to identify trends and perform analyses that can inform business requirements in the future. Other cloud options like Amazon Redshift and Snowflake exist but may be more expensive to use.

    Apache Storm — Distributed Real-Time Computation for Search and Recommendation engine results

    While Hadoop handles batch processing, Apache Storm is for optimized for real-time analytics. Storm is open source as well, and extremely fast clocking in at over a million tuples processed per second per node. It can be used for real time analytics, online machine learning, continuous computation, distributed RPC, ETL and more.

    Google Cloud Bigtable — Highly Available NoSQL Cloud-based DB storing song, playlist, artist, and podcast metadata

    Google Big Query likely pulls data from Bigtable to form its data warehouse and make ETL easier to perform. So, the main reason for using Bigtable may be its interoperability with Google Big Query, but lower charges could be another reason as well.

    During development, the Spotify team also used the following tools for Test Automation and DevOps during development:
    Docker — App Containerization (Run Apps in Production-Ready Environments Remotely on any OS)
    New Relic — Stack Monitoring and Security
    Datadog — Stack Monitoring and Security
    Percy — Automated Visual QA
    Apache Cloudstack — IaaS
    Testflight — Testing framework for iOS
    Helios/Kubernetes — Container Orchestration (scales Docker Containers according to Load)

    Note the above tools are the ones Spotify personally chose to use, either because they were cost and performance efficient, independent of third parties (open source), or met current staffing requirements.

    These tools are integrated in the following dataflow diagram:

    spotify_design

    The diagram above shows that data flows from frontend to backend in the following steps.

    • The client first interacts with the frontend (like searching a songs name).
    • The frontend then sends this request to the NGINX load balancer which forwards the request to an NGINX API gateway that can check if the user is authenticated and decide which microservice network will handle it.
    • The NGINX API gateway sends the request to an NGINX service client instance, with the Hysterix circuit breaker checking if a service client is down (redirecting to a different service client in case it is).
    • The NGINX service client then either searches the Redis cache if the request stores a response to send back, if not it publishes the request to the Kafka pipeline.
    • Like an inbox, every microservice subscribed to the Kafka pipeline can look at the published request.
    • Microservices capable of responding back publish the response on the pipeline. This is where microservices can talk to other microservices. For example when searching, Google Bigtable might be queried by Apache Storm to generate search results to send back, with Apache Storm publishing the final search results to the pipeline.
    • The service client reads the most recent responses on the pipeline, and pools together the responses to send back to the NGINX API gateway.
    • The NGINX API gateway sends the response to the NGINX load balancer and eventually to the frontend, modifying it someway (in the application of searching, the front end renders the response, a set of search results.)
    • At this point if the user takes another action like selecting a song, the process is repeated, with different services used. For example, playing a selected song sends a request to Spotify’s CDN through a direct connection to the load balancer. This speeds up the process for a client to access audio.

    Alternative Tools

    Alternatives for the following tools are:
    API Gateways/Load Balancers: AWS, Azure, Google Cloud, Zuul, Linkerd
    Databases: Redis, MongoDB, Amazon Dynamo DB, Firestore, Couchbase
    Caching: Redis, Memcached
    Data Processing: Hadoop, Apache Spark, Apache Storm, Google Compute Cloud, AWS EC2
    CDN Providers: Azure CDN, Cloudfare, AWS Cloudfront, BunnyCDN, CacheFly
    Pipelines: AWS Kinesus, Apache Spark, Apache Storm, Kafka, RabbitMQ, RAITMQ, ActiveMQ
    APIs: REST, JSON RPC, GraphQl, Web Sockets
    Backend Frameworks/Tools: .NET, Spring, Node, Django, Laravel
    Frontend Frameworks/Tools: ReactJS, Vue, Angular, Django, PHP, HTML/CSS, JavaFX, Blazor

    7. Conclusion

    Spotify is an extremely complex application, but the architecture it uses remains fundamentally the same for other content delivery applications. Microservices is an architecture that takes advantage of the benefits of modularity and loose coupling to offer the best end-user experience for millions of users.

    With this article at OpenGenus, you must have the complete idea of System Design of Spotify.

    Technologies and programming language used by Spotify

    Spotify is the world’s most popular and largest music and video streaming subscription service, allowing you to search and listen to millions of songs and music from a wide range of artists all over the world. It began in October 2008 as a Swedish audio streaming and media service with a few songs, but it now has 70 million songs in its library, with 60000 added every day.

    Spotify has 365 million users as of 2021 and is rapidly growing. It currently has 2.9 million podcasts in its library and is available in 171 markets, with 44 percent of daily users using Spotify. It dominates the way we consume music in the twenty-first century.

    You may be wondering how Spotify processes these millions of data and user records, as well as what programming language and technologies are used to create the powerful Spotify Technology Stack.No worries, guys, I’ll assist you in obtaining this information.

    Table of Contents

    1 Programming Language

    Spotify uses a variety of programming languages for building tech stack some of them are Python, Java, C++, Closure, etc. fig. main programming language used in Spotify

    Python

    Python is used by Spotify for backend services, quick scripts, build processes, and data analysis. Approximately 80% of services are written in Python and are linked by Hermes, a message-based messaging protocol built on ZeroMW and protbuf. They chose Python because it is simple to write and shortens the development cycle. (source python at Spotify)

    It is estimated that approximately 90% of Spotify map-reduce jobs are written in Python.

    Java is said that Non-Python services are typically written in Java. Spotify uses a Java SE subscription which provides all Java SE licensing and supports(source). Java is very fast, well documented with over many active developer communities. They also use Java for Android.

    Some of the shared code based is written in C++ and other platforms adopt it.

    Objective-C

    Objective-C for iOS applications

    2 Big Data Tools

    Big Data Tools : Spotify

    There are various tools used for storing and maintaining a large amount of variety of data. Spotify Big Data Tools

    Apache Hadoop

    Spotify has millions of users, songs, music, and podcasts. It is difficult to analyze this type of data and generate useful insights. As a result, for complex analysis, a «data lake» based on Hadoop is used.

    Spotify used it to assist in training machines for better track and music recommendations to users, calculating royalties, serving user-intentioned ads, measuring audience response to new features and functions, and generating business reporting marketing campaigns, etc.

    According to this 2017 blog, Hadoop handles big data inflows with a 2500-node on-premise Apache Hadoop Cluster for Spotify.

    Apache Spark

    Apache Spark is a distributed processing system used for big data workloads.

    Apache Spark is used by Spotify for machine learning application sections, taking advantage of in-memory caching and optimizing query execution for fast queries against any volume of data.

    Apache Storm

    Spotify made use of Apache Storm to power real-time use cases such as new user suggestions, ad targeting, and product metrics as Apache Storm is a leading tool for real-time processing information.

    3 Data Pipelines

    One of the popular Data Pipelines tools used in Spotify is Luigi.

    Luigi

    Luigi is a Python-based ETL tool that feeds Spotify’s Hadoop data intelligence activities. It aids developers in scheduling, monitoring, and managing batch jobs rather than continuous, streaming activities. It handles the plumbing for Hadoop jobs.

    Google Cloud Pub/Sub

    In 2016, Spotify’s Event Delivery Solution is powered by Google Cloud Pub/Sub. They used to use Apache Kafka before.

    4 DevOps

    Following are the DevOps tools used in Spotify: Docker, New Relic, Datadog, Pingdom, Percy, Apache CloudStack, Helios, etc.

    Docker

    Docker is a lightweight standalone virtual machine that comes preloaded with all of the programs and dependencies you’ll need to run your program. It simplifies the creation, deployment, and execution of any application.

    New Relic

    New Relic functions as a service that assists website and application owners in tracking the performance of their web apps. It performs like a real-time performance dashboard with X-ray vision. New Relic assists in locating actual problems in apps.

    New Relic removes the burden of monitoring, identifying, troubleshooting, and scaling the web app from your shoulders and makes it simple for you.

    Datadog

    Datadog is a monitoring, security, and analytics platform for cloud-based applications and is useful for developers, IT operators, security engineers, and business users. It provides monitoring of servers, databases, tools, services, and many more.

    Pingdom

    Pingdom is a website performance and availability monitoring tool.

    Apache CloudStack

    CloudStack is an open-source cloud computing management platform that allows you to create, manage, and deploy various cloud services. Some of Apache CloudStack’s key features are as follows: Built-in high availability for hosts and VMs, user-friendly Web-based UI for cloud management, Management of snapshots, accounting of network, compute, and storage resources, usage metering, virtual routers, firewalls, and load balancers, and so on.

    Percy

    Percy assists teams in automating visual testing. Percy renders and compares snapshots from different browsers and screens in order to detect, highlight, and group visual differences.

    Helios

    Helios is an orchestration tool built on top of Docker that enables users to deploy and manage containers across a full fleet of machines.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *