So, who is Souncloud?

Founded in Stockholm, but established in Berlin, Soundcloud is an audio distribution platform. It enables their users to upload, record, share and promote their original songs.

Beginning with an idea of sharing tracks, much like we share videos on Vimeo, for example, instead of sending them via private way, it rapidly grew becoming the most used audio platform. Nowaday, it counts with 1900+ workers and a registered user base of 40 million.

Concurrency in Android

Soundcloud has to deal with a lot of concurrent API calls. Based on 2013 data, it has to manage 12 hours of audio added every minute, try to reach 200 million of users per month, more than 14 million app downloads. Today, this numbers are even bigger.

In depth, the Android app must do a lot of tasks, in background, since, natively, it can't block UI thread. We're talking about network calls, UI calls, and a lot of other things that you can think of.

If you are to implement this, by hand, then you'd probably come up with spaghetti code, meaning, you'd have a ton of nested AsyncTasks, inline threads or none at all and probably a galore of custom callbacks.

So, Soundcloud decided to streamline their event handling, embrace concurrency and, more important, unify the event model. Which tecnhology does this better, they thought. RxJava came up!

Explaining the Problem

Let's sum this up. Why did a growing digital business like Soundcloud need to find a better architecture?

As you can see, there are a lot of variables to work with, while developing an Android app. How you manage them is, probably, the key to success.

Performing asynchronously is a must-have feature, so our programming style should reflect it. Souncloud team knew that and decided to go with RxJava so they could solve the problem in a scalable way.

Though, there are not silver bullets in software engineering. You'll always have to analyse the pros & cons of the used techology.

Enter RX

The concept here is the same as Netflix, so please click here. It will lead you there.

Conclusion

  • Using RxJava, Soundcloud development team could abstract from asynchronous behaviour implementation.
  • This level of abstraction improves code mantainability, as well as performance and scalability.
  • Multiple soundcloud teams could develop the services as they see fit, since their API is exposed as an Observable(T). This means it will always work with the set type