Please enable JavaScript.
Coggle requires JavaScript to display documents.
System design, CDN- Content Delivery Networks, Microservices, EVENT DRIVEN…
System design
steps
-
-
- Understand problem, establish design scope
-
-
-
-
-
-
-
-
-
-
-
NoSQL DB
CASANDRA(FB)
-
casandra claster consist of 5 nodes, Keyes destribute by hash function
-
-
QUORUM
if quorum = 2 - request to node5-> save data in 5, 1, 2 -> 5 crash-> serch data in 1 and 2. If both dont have data -> error, if have-> send responce
Request to CASANDRA
-
update
update will create copy of the record with timestamp - if you want to read - need take data with latest timestamp
-
-
pros
-
-
flexible
value - it just JSON, and no matter schema
-
-
-
-
-
-
-
TikTok
need ask about
-
-
-
-
low latency between upload and user visibility, low latency when distributed video on stream
-
user app
user data, user metadata, user video
-
-
-
-
-
storage - 200K video per day
200K*1Mb = 200GB for one format - for 4 formats we need 600GB - some videos would be smaller
diff resolutions ~ 1,2 TB per day
Distributed cashing
cash pros
-
-
-
-
save most relevant info, predicted data
-
-
-
-
Problem with failure
-
-
celebrity(popular) post
-
add jitter
don't show all metadata - just show an approximation(aproximate statistics) - general tendency - it decrees number of requests to DB
-
-
DB
sharding - partitioning - divide data, one pice - 1 server (by location, id....)
consistency
availability
problems
-
memhashed (not only about consistent hashing can be applyied on bussiness logic) can't have flexibele ammount of shade - have FIXED AMOUNT OF SHARD -to fixe it can use HIEARCHICKAL SHARDING(split one shard to smaller pieses) - it gives flexability
advantage
-
-
have master slaves for reading, writing - master. When master fall can choose master from slaves
-
-
-
WhatsApp
fichers
sent, delivered, read reciepts
-
-
-
-
-
-
-
-
-
SQL DB
-
-
we have foreign key mapping, have relationship between objects
-
-
Message/task queue - monitor heartbeats and when one of the servers don't response - redirect request to another server using CONSISTENT HASHING
-
-
-
Tinder architecture
Main points
-
-
-
dirrect messaging
user1->request (messageTo(user2) XMPP or HTTP-> gateway-> ..->XMPP(peer-to-peer protocol - it push user when message is comes but not user pushes server)
-
-
-
Event Driven services
use Publisher - Subscriber module - use MESSAGE BROKER (send message asynchroniusly between servises) - Kafka
-
advanteges
-
some transaction capability - garanty when you send a message once and get response - ok it 100% will be done in future
-
-
disadvantage
-
not good idea for banking account, financial app
poor consistency, there is not atomicity
-
-
-
-
-
CAP teorem
CONSISTENCY(DATA)
-
2 phase commit
have veraity of servers - 1 is leader and others followers - leader made update, others only read
leader sand request with commit to other servers - they give ACK(we get) to leader -> leader send command with prepare statements - commit _> others give ACK
-
-
-
-
-
-
-
-
-
-
-
-
NEW YEAR
deprioritizing messaging - deliver only nessesary message, exclude unnessesary fiatures
-
-
-
-
-
-
Streaming events(video)
protocol - RTMP
-
used by Facebook, Youtube life
HTTP - send request from client to server and client get response, but it dont give abbility sent request from service to user
-
System design is the process of defining the architecture, interfaces, and data for a system that satisfies specific requirements.