Wednesday, 19 September 2018

System design : design an appstore like google playstore

First of all we need to figure out the features that we need for our appstore. Lets list them one by one.

Login
- User page
   - Basic details
   - Mobile OS
- view already submitted apps
- apps detail page
- Install feature 
   - Check for the compatility of OS
   - Download
- Publisher page
   - Upload feature
   - Permission required
   - How do we store these binaries ?
- App search
- Roll out updates

Ok ! we are almost done with the requirements. Main points to be taken care for this application should be ..

- How do we upload files ? What are the different protocols ?

Lets go in detail and find out how does the file transfer works internally. Main protocols that are used for file transfer are,

FTP - FTPS(secure) &  HTTP - HTTPS(secure) 
SSL is used to secure the protocols for file transfer where it will encrypt the contents before sending. 

Understanding the basics
If you want to dive deep into the actual implementation of the FTP or HTTP , then we need to start from the basic OSI layers. Different layers of the OSI work together to transmit data from one host to another remote host.

Good understanding and explanation of the OSI layers can be found here. Basic network concepts and terminologies are found out here as well. TC/IP details can be found out in this link.

Read more about how FTP works here.

The question was whether we should use FTP or http. ftp is a clear winner in case of transfer speed, but properly tuned http can counter that by parallel processing of chunks. ftp's security i still a concern as most of the firewalls will stop it. nowadays ftps are becoming obsolete. the large file transfers can be done with http. So n network application http is a better option for large file transfer.Since our use case of app binary files will be smaller in size , we will sure surely use http based file transferring.

Some of the techniques that can be used for transferring large files are chunking, file streams etc. Here is a good article on large file transfer over http.

- How does we store all the binary files ?

We can store these files in a file server for mostly active files and web can move it storage servers once it having less activities.

File server is used for sharing/distributing large-sized files amongst a large group of users across multiple locations. These have high-speed connectivity & high amount of bandwidth.
File storage server is used to host synced or backed-up files from PCs and smartphones. These are not used to share files and typically have large amount of storage and low-to medium speed connectivity with high bandwidth.
- Make it highly available




API design
Data modelling



Spring important links to check out

If you want to read about Spring life cycle, how to add actions in between the spring life cycle methods or how to use *aware interfaces like ApplicationContextAware interfaces -  Read this link

Do you want to understand how dependency injection works ? Or want to know about the types of DI ? Or even why one should not use @autowired ? See this link

Want to look at different annotation available ? here it is

Java Thread : Brush up links

Threads are most important topics for any java interviews. Knowing thread deeper will give you extra impression on the interviewer as threads are relatively untouched & difficult section of java for most of the java developers. I am listing the basic thread related links that i have came across and hopefully this will help you to prepare for your next java interview.

First of all we need to get hold on the basics of the thread concepts in java including creation, race conditions, locks etc. You can refer this article for basics. Before that if you want to learn how OS deals with threads and what are the different types of concurrency available then this article will give you an excellent write up about the back ground. The blog callicoder has listed all the major topics very clearly with examples with Java 8. Please check all the blog series in the left panel. It talks about executor service, callable, synchronization and locks. Atomic variables are thread safe option as well. So we need to understand how atomic variables take of thread safety. You can find the article here.

Java 1.5 has introduced a number of concurrent collections and it is very important to know about these utilities during interviews.

ThreadLocal - In Details
BlockingQueue
Counting Semaphore




This article will help you write your own thread pool from scratch. It's worth reading.