Jump to content

to session or not to session


Recommended Posts

On a site like facebook, where they must make tonnes of sql statments on each page.. do you think that they for example

check to see if you are friends with a user on each page.. or do they do it just once and store the result in a session...

obviously it makes sense to store it in a session.. however it is easier to just do the request 'see if they are friends' on

each page rather than having to check if sessions exists.. and if the session is for that friend... etc.

Link to comment
Share on other sites

I would imagine that a site as big as Facebook would be using sessions that are stored inside a database, and not on the filesystem.

 

I've done this before and found that it's not that big a performance issue, providing you use proper indexing.

 

<?php
if($logged_in){
    $are_friends = $user->are_friends($_GET['uid'],$_SESSION['user_id']);
}
?>

Link to comment
Share on other sites

I would imagine that a site as big as Facebook would be using sessions that are stored inside a database, and not on the filesystem.

 

I'm pretty sure they would be using something like memcached. You should be fine storing the session data in a database. The forums a main site here do that actually.

Link to comment
Share on other sites

Man. I can't even imagine the extent of the performance issues that Facebook runs into daily. Their source was leaked a while ago. Server error or misconfiguration dumped all the code on the login page. Although it didn't reveal the inner workings, it did look as if they were using Smarty - or some sort of custom template system.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.