General Concepts Flashcards

1
Q

What is Ajax-Polling? How does it work? What are its downsides?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is HTTP-long polling?

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are WebSockets

A

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/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are SSEs?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a framed protocol

A

A protocol where by a chunk of data is divided into discrete chucks with some parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the locality reference principle?

A

Recently requested data is likely to be requested again. Cache is basically a product of this principle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a cache, where is it found

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an application server cache

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an issue with expanding a cache too many server nodes

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a CDN. What are they used for.

Who are some big providers?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is cache invalidation? What are the 3 main schemes to solve it?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What ar some cache eviction policies?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are message queues? What are they use for ? What are examples of mq softwares?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is map reduce

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a forward proxy?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a reverse proxy?

What are some good usecases?

A

A reverse proxy is a server that sits in front of one or more web servers, intercepting requests from the clients before they hit hte origin server at the ‘network edge’. This is in contrast to a forward proxy making requests on behalf of a client (and sits right in front of a client ).

Use Cases:

Laod Balancing - use a reverse proxy to redirect traffic to a group of servers. It can hold logic for redirecoitn as well.

Attack Protection - again since only the reverse proxy servers IP is expoxed.

Caching - a reverse proxy can also cache content. Can make user experience faster. For example if a paris user makes a request to los angeles, a paris reverse proxy may cache that for future parisian users to benefit from and respond from its cache.

GSLB - Global server load balancing - load balancing across the globe, minimizes load times.

SSL/TLS encryption - encrypting decrypting SSL using a public and secret key.

17
Q

What is a DDos Attack

A

A distributed deniel of service attack is an attempt to disrupt normal traffic of a target server , service or netowrk by flooding it with internet traffic.

It works by using multiple computers/iot devices (that havebeen compromised to use), to provide the attack traffic.

Solutions to this can be a black hole routing, rate limiting, web application firewall (WAF) for custom logic, any cast network diffusion to spread traffic accross a distributed system

18
Q

What is SSL and TLS. What are they used for and how does it relate to HTTPS. How does the process work?

A

SSL is secure socket layer and TLS is transport layer security. Modern secruity is using TLS but often misidentified as SSL which hasn’t been updated since 1996.

Their main purpose is to encrypt and decrypt traffic to and from websites. HTTPs is an implementation of TLS. This is done through secret and public key generation from both sides during an initial handshake.

In order to use TLS the origin server must have a TLS certificate issued by a certificate authority so that a person or busienss is verified.

19
Q

What are the Steps in a good system Design interview

A
  1. Ask clarifying questins. Get Requirements.
  2. BOTE estimation.
  3. System interface definition/ API definition for what we need to provid eand get form teh system. Good step for if we undestand requirements right.
  4. Define data model - good for getting requirements and for guiding scalability.
  5. High level design - draw box diagram with 5-6 boxes repping the core system components
  6. Detailed Design - go further into a few components. How to partition db, hwere to insert cache, how to store data, which components need load balancing
  7. Identify and resolve bottlenecks. Where are the single points of failure. What are we doing to mitigate it. Is there enough replication/redundancy. How are we monitoring failures