General Concepts Flashcards
What is Ajax-Polling? How does it work? What are its downsides?
This is traditional polling. Ajax Polling - 1) client opens a connection 2) sends regular requests(like 0.5 seconds) 3) The Server Responds. 4) The client repeats the above three steps to get updates from the server. Problems: - If often server responses are empty then there is a lot of bandwidth wasted making requests by the web page, creates HTTP overhead
What is HTTP-long polling?
This is a variation of traditional Ajax polling that allows the server to ‘push’ information to a client when information is available. 1) Client makes initial request using regular HTTP, waits for a response 2) server delays its response until an update is available or a timeout has occurred 3) When an update is available, the server sends a full response 4) Client typically sends a new long-poll request either immediately upon receiving response or after a pause to allow an acceptable latency period Downsides 5) Each Long-poll request has a timeout, client has to re-connect periodically due to timeouts Also called “Hanging GET”
What are WebSockets
1) a full duplex communication method over a single TCP Connection, good for realtime communication 2) provides consistent connection between client and server that both can use to start sending data at any time 3) starts life as an http connection, after a handshake and an ‘upgrade’ the web socket is borne and persists till both parties take it down. Extra: They don’t use http:, they use a ws: or wss: (wss secure) as the uri prefix https://sookocheff.com/post/networking/how-do-websockets-work/
What are SSEs?
Server-Sent Events Client establishes persistent long term connection with the server. Server uses this connection to send data to client. 1) Client requests data from server using HTTP 2) requested webpage opens a connection to the server 3) server sends the data to the client whenever there’s new information available. SSEs are best when we need real-time traffic from server or to the client or if server is generating data in a loop and will be sending multiple events to the client
What is a framed protocol
A protocol where by a chunk of data is divided into discrete chucks with some parameters.
What is the locality reference principle?
Recently requested data is likely to be requested again. Cache is basically a product of this principle
What is a cache, where is it found
It is a in-memory store of data, and often is closer to the front end in system design. However it occurs on all layers of architecture.
What is an application server cache
A cache placed on a node request layer. It stores responses for frequently requested information. It could be placed in memory(very fast) or local storage(still faster than db).
What is an issue with expanding a cache too many server nodes
If each node has its own cache, you could increase the chances of ‘cache misses’. As requests will only cache locally and load balancers could distribute similar requests to caches that doen’t have the request cached. Two solutions are global caches and distributed caches.
What is a CDN. What are they used for.
Who are some big providers?
Content Distribution Networks are caches that serve static media for a large amount of requests. If system we’re building isn’t large enough yet to have its own CDN, we can ease a future transitionary serving static media off a separate subdomain, using a light weight http server like Nginx. Then move the DNS mapping to a CDN later.
Major CDNs - Cloudflare, Amazon CloudFront, Fastly, Azure CDN.
What is cache invalidation? What are the 3 main schemes to solve it?
Cache invalidation is when cache data becomes stale after a write to the db. 3 schemes: Write Through Cache: Data is written into cache and the corresponding database at the same time. Ad: allows for fast retrieval. No data inconsistency Dis:All write operations done twice, higher latency Write Around Cache: Data written directly to permanent storage, bypassing cache. Ad: cache is not write flooded for reads that are uncomment Dis: recently written records will have ‘cache misses’ and have higher latency Write-back cache: Data only written to cache, then written to storage at intervals. Ad: highest speed for reads: Dis: greatest loss potential on crashes
What ar some cache eviction policies?
FIFO - first in first out LIFO - last in first out LRU - discards least used items first MRU - discards recently used items first LFU - counts how often items are hit, discards the least RR - discards at random
What are message queues? What are they use for ? What are examples of mq softwares?
Message queues allow server or web server to publish items to a queue where a server can consume those items. Allows for highly asynchronous functionality for softwares and makes a highly distributed system. Makes actions more consistent rather than dealing with bottle necks. Can get back to user or respond to request quickly and update just enough to make it seems like task is done (aka my timeline is updated but my friends is not) while scheduling the rest of the task. Softwares: Kafka, Rabbit MQ
What is map reduce
Hadoop/Hhive - A layer of software used to parse through a lot of data.
Steps are map, shuffle and reduce to efficiently paralell process lots of data (text or otherwise).
What is a forward proxy?
A Forward proxy (proxy, proxy server, web proxy) is a server thats sits right in front of a group of client machines. It forwards requests from the client to the internet (various origin servers).
Uses for foward proxies could be to create firewalls (restrict access to parts of the internet) or by pass firewalls. They could also be used to generally protect ones identify while on the internet, as only the proxy server’s ip will be exposed.