What are the top 10 things that we should be informed about, in life?

As ambiguous and ridiculous this question sounds, I hope you get the gist of what I mean. What main things should a person know about in life? Whether it be their government, types of awareness in any particular subject, anything would be great to hear!

View Question on Quora

Varnish–Power Booster for Facebook

One thing most of people does not know is that, most of the Facebook request mostly does not reach the HDD i.e. hard disk.Most of the requests remain in the cache buffer of Facebook (Memcached for Facebook) .We have seen what basically MemCached in one of the post , now the turn comes is of Varnish, the power booster which picks up every requests in Facebook and sends to the servers,that is it is a reverse proxy.

Varnish Request-Response Model

 

 

 

 

 

 

 

 

 

 

Above photo shows  the best easy diagrammatic representation of how does Varnish work.Varnish is heavily threaded, with each client connection being handled by a separate worker thread. When the configured limit on the number of active worker threads is reached, incoming connections are placed in an overflow queue.Thereby only when this queue has reached its limit then the incoming connections will be rejected.

According to data known, there are following things occurring in Facebook in next 60 seconds :
6,96,000+ Facebook status updates, 5,10,000 comments.

Caching is vital for high-load applications. A typical web application serves a lot of content that costs much more to generate than it costs to cache (including the cost of checking and expiring the cache), so caching can usually improve performance by orders of magnitude.

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is too fast. It typically speeds up delivery with a factor of 300 – 1000x, depending on your architecture.

It serves billions of requests every day to Facebook users around the world. Whenever you load photos and profile pictures of your friends, there’s a very good chance that Varnish is involved.

A normal proxy redirects the server request through its proxy server, whether via LAN or anonymously and then sends the request to the concerned server. This helps to hide the identity of the original user.
In normal way the cache is more stored either on server.To avoid this a reverse proxy like Squid or Varnish is used.In reverse proxy the compression and load balancing of data is done on the client side.

One of the main feature ( and the BEST feature according to me) in varnish is that it has two modes in it,which makes it enormously useful to network administrators and web programmers to handle requests according to the behavior of   request.The following article will be posted  about that two modes.Until that time,read this article carefully.

Optimization of News Feed in Facebook

The Facemash algorithm that I had posted here was just a “trailer” of this actual post for starting understanding Facebook.

Facebook used basically a data structure,called graph.Graph includes two basic things:

1.Nodes with their corresponding value

2.Edges between nodes with their corresponding weight

Whatever you observe in Facebook mainly is always the News Feed, which is the most important feature of Facebook.

So it is always needed  to carefully choose which posts to publish on the first page of your News Feed. So the main component of your News Feed and at last of your Facebook page is optimization of News Feed.

Below photo shows formula used by Facebook to optimize the News Feed of Facebook profile.

As shown in above photo, the friends and relationships and post by any one of them are based on three parameters:

1.Weight of edge type

2. Time from which they were friends and how ago the post was posted on Facebook

3. How closer the friends i.e. in same school or just a fan of other friend

Thus,the sum of product of all your friends and “weight” of your relationships with them is what you see in the News Feed of your Facebook profile.

So the better you are friends (it can be known by a simple Facebook app,whose making we will discuss later)  the more are the chances that your post will be on the News Feed of other one. Similarly , the more you interact,more is the chance is there that you are featured on the News Feed of your other friend.

 Four Your Information(FYI):

Depending on your number of friends and their activity, a click to your News Feed can call up as many as 10,000 stories that account for about 8 megabytes of space. All this occurs in about seven-tenths of a second.

Algorithm for facemash

You must be remembering this scene from The Social Network movie,when Eduardo Saverin writes an algorithm for making facemash.com.

Actually,the algorithm is a simple algorithm to rank the players of chess,named Elo rating System.According to wiki:

The Elo rating system is a method for calculating the relative skill levels of players in two-player games such as chess.

Algorithm:

According to this algorithm following represents the expected score of for example,Player A

Similarly the expected score for example,Player B is:

Where RA is current rating of Player A and RB is current rating of player B.

When player A will play the match whatever score he has,it will be compared with the expected score and that will give a new rating for player A. This will be done using the below formula;

Where SA is the actual score of player A. K is a constant that has two values for Master players K=16 and for weaker players K will be 32.

Let us take an example of rating girls as done in the Social Network movie. For example we have the following table:

Girl Current Rating Result Score

A

80

B

90

Lost 0

C

30

Won 1

D

50

Draw 0.5

E

40

Won 1

Now as you can see clearly that A was compared with 4 girls and she has scored 2.5 points. If you calculate the expected score using the above formula it will be as follows :
                    
                     2.157(0.485+0.572+0.543+0.557).

Now using the second formula given above we will calculate the new Rating for player A  using K = 16  will be

                     R’A = 80 + 16(2.5-2.157) = 85.2

That’s all about the algorithm.Anything more should be reflected in comments.