Shared Variable Vs. Session Variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Kraft

    #1

    Shared Variable Vs. Session Variable

    Hi all,

    My question is more of a phylisophical one here, but I am wondering what
    the difference is (effectively and performance wise) between using a
    shared variable/static variable and using a session variable.

    I have two different applications right now that effectively perform the
    same action at one point. In the one application I created a shared
    variable:

    shared myTable as DataTable;

    In the other application I used a session variable:

    session("myTabl e") = myTable;

    Both of these ways "seem" to perform identically... that is they both
    produce the same end result when I use them.

    What's your view on this?

    John Kraft

  • Marina

    #2
    Re: Shared Variable Vs. Session Variable

    Shared variables are shared by every user using your web app. They last
    until the web app shuts down.

    Session variables are specific to a particular user. These last only for the
    life of the session. If the session timeout is set to 5 minutes, after 5
    minutes of inactivity the session is over, and the variable's value is gone
    with it.

    Session variables are going to be more costly as you are going to have a
    copy of them per user.

    The types of variables do not perform identially. If you have 2 people
    accessing your application, they will share a copy of the Shared variable.
    User1 can modify it - and User2 who accesses it afterwards sees the changes
    User1 made.

    With session variables, each user has their own copy of the variable, and do
    not overwrite each other's changes.

    "John Kraft" <jhkraft@nospam .ilstu.edu> wrote in message
    news:bn42g7$7ke $1@malachite.il stu.edu...[color=blue]
    > Hi all,
    >
    > My question is more of a phylisophical one here, but I am wondering what
    > the difference is (effectively and performance wise) between using a
    > shared variable/static variable and using a session variable.
    >
    > I have two different applications right now that effectively perform the
    > same action at one point. In the one application I created a shared
    > variable:
    >
    > shared myTable as DataTable;
    >
    > In the other application I used a session variable:
    >
    > session("myTabl e") = myTable;
    >
    > Both of these ways "seem" to perform identically... that is they both
    > produce the same end result when I use them.
    >
    > What's your view on this?
    >
    > John Kraft
    >[/color]


    Comment

    • Marina

      #3
      Re: Shared Variable Vs. Session Variable

      Shared variables are shared by every user using your web app. They last
      until the web app shuts down.

      Session variables are specific to a particular user. These last only for the
      life of the session. If the session timeout is set to 5 minutes, after 5
      minutes of inactivity the session is over, and the variable's value is gone
      with it.

      Session variables are going to be more costly as you are going to have a
      copy of them per user.

      The types of variables do not perform identially. If you have 2 people
      accessing your application, they will share a copy of the Shared variable.
      User1 can modify it - and User2 who accesses it afterwards sees the changes
      User1 made.

      With session variables, each user has their own copy of the variable, and do
      not overwrite each other's changes.

      "John Kraft" <jhkraft@nospam .ilstu.edu> wrote in message
      news:bn42g7$7ke $1@malachite.il stu.edu...[color=blue]
      > Hi all,
      >
      > My question is more of a phylisophical one here, but I am wondering what
      > the difference is (effectively and performance wise) between using a
      > shared variable/static variable and using a session variable.
      >
      > I have two different applications right now that effectively perform the
      > same action at one point. In the one application I created a shared
      > variable:
      >
      > shared myTable as DataTable;
      >
      > In the other application I used a session variable:
      >
      > session("myTabl e") = myTable;
      >
      > Both of these ways "seem" to perform identically... that is they both
      > produce the same end result when I use them.
      >
      > What's your view on this?
      >
      > John Kraft
      >[/color]


      Comment

      • Cowboy \(Gregory A. Beamer\)

        #4
        Re: Shared Variable Vs. Session Variable

        Have a couple of people hit the app at the same time as you and have them
        choose different variables to set up myTable. Then, you will see the
        difference between Shared/static and Session.

        I worked on an app where another developer set up a static function to
        retrieve info. It did not manifest through the pilot, as there was not
        enough activity. Put into production, users began to see cities outside of
        their control, as the city was cached in a static property. Ouch!!!

        If the variable is application wide, static is fine. If it gets altered on a
        per user basis, you will either have to cache in a static array, or use
        session. The advantage of session is it drops out when the session dies.

        NOTE: Behind the scenes, in .NET, static and session are fairly similar, as
        session objects are cached statically.

        --
        Gregory A. Beamer
        MVP; MCP: +I, SE, SD, DBA

        *************** *************** *************** *************** **********
        Think Outside the Box!
        *************** *************** *************** *************** **********
        "John Kraft" <jhkraft@nospam .ilstu.edu> wrote in message
        news:bn42g7$7ke $1@malachite.il stu.edu...[color=blue]
        > Hi all,
        >
        > My question is more of a phylisophical one here, but I am wondering what
        > the difference is (effectively and performance wise) between using a
        > shared variable/static variable and using a session variable.
        >
        > I have two different applications right now that effectively perform the
        > same action at one point. In the one application I created a shared
        > variable:
        >
        > shared myTable as DataTable;
        >
        > In the other application I used a session variable:
        >
        > session("myTabl e") = myTable;
        >
        > Both of these ways "seem" to perform identically... that is they both
        > produce the same end result when I use them.
        >
        > What's your view on this?
        >
        > John Kraft
        >[/color]


        Comment

        • Cowboy \(Gregory A. Beamer\)

          #5
          Re: Shared Variable Vs. Session Variable

          Have a couple of people hit the app at the same time as you and have them
          choose different variables to set up myTable. Then, you will see the
          difference between Shared/static and Session.

          I worked on an app where another developer set up a static function to
          retrieve info. It did not manifest through the pilot, as there was not
          enough activity. Put into production, users began to see cities outside of
          their control, as the city was cached in a static property. Ouch!!!

          If the variable is application wide, static is fine. If it gets altered on a
          per user basis, you will either have to cache in a static array, or use
          session. The advantage of session is it drops out when the session dies.

          NOTE: Behind the scenes, in .NET, static and session are fairly similar, as
          session objects are cached statically.

          --
          Gregory A. Beamer
          MVP; MCP: +I, SE, SD, DBA

          *************** *************** *************** *************** **********
          Think Outside the Box!
          *************** *************** *************** *************** **********
          "John Kraft" <jhkraft@nospam .ilstu.edu> wrote in message
          news:bn42g7$7ke $1@malachite.il stu.edu...[color=blue]
          > Hi all,
          >
          > My question is more of a phylisophical one here, but I am wondering what
          > the difference is (effectively and performance wise) between using a
          > shared variable/static variable and using a session variable.
          >
          > I have two different applications right now that effectively perform the
          > same action at one point. In the one application I created a shared
          > variable:
          >
          > shared myTable as DataTable;
          >
          > In the other application I used a session variable:
          >
          > session("myTabl e") = myTable;
          >
          > Both of these ways "seem" to perform identically... that is they both
          > produce the same end result when I use them.
          >
          > What's your view on this?
          >
          > John Kraft
          >[/color]


          Comment

          Working...