Performance and context switching

Discussion in 'ASP .Net' started by robm, Sep 21, 2007.

  1. robm

    robm Guest

    Hi,

    We have an ASP.NET 2 application that does some quite intensive work
    in order to present data to the users. A particular function gathers
    a lot of data from the database and as the objects are quite fine
    grained it makes thousands of stored procedure calls. When under no
    load the performance is fine, but when a few users use this at once
    then the performance declines. With around 4 users executing this
    intensive function at once, using performance monitor we see around
    40% CPU usage but massive levels of context switching (~300 000/sec).
    I understand that context switching increases with the number of
    threads, but it doesn't seem to me that this web server is under
    particular load (it's a fairly well spec'd server with dual-processor,
    dual-core). If the CPU was maxed out I would just assume that the
    server couldn't cope with the load that we are putting it under, but
    it's not so it appears we are hitting some other server limit. Can
    anyone give me any pointers about what could be causing such huge
    context switching values?

    Thanks,
    Rob
    robm, Sep 21, 2007
    #1
    1. Advertising

  2. robm

    bruce barker Guest

    every call to the o/s is a context switch. every i/o interrupt is a
    context switch. as the database calls use the network, every packet is a
    context switch.

    most likely you are hitting blocking with database and thats your
    limiting factor. you should not be doing 100's of sp calls per page
    request, much less 1000's.

    read the chapters on set operations and joins and try to get the sql
    calls to 10 - 50 a page request.

    -- bruce (sqlwork.com)


    robm wrote:
    > Hi,
    >
    > We have an ASP.NET 2 application that does some quite intensive work
    > in order to present data to the users. A particular function gathers
    > a lot of data from the database and as the objects are quite fine
    > grained it makes thousands of stored procedure calls. When under no
    > load the performance is fine, but when a few users use this at once
    > then the performance declines. With around 4 users executing this
    > intensive function at once, using performance monitor we see around
    > 40% CPU usage but massive levels of context switching (~300 000/sec).
    > I understand that context switching increases with the number of
    > threads, but it doesn't seem to me that this web server is under
    > particular load (it's a fairly well spec'd server with dual-processor,
    > dual-core). If the CPU was maxed out I would just assume that the
    > server couldn't cope with the load that we are putting it under, but
    > it's not so it appears we are hitting some other server limit. Can
    > anyone give me any pointers about what could be causing such huge
    > context switching values?
    >
    > Thanks,
    > Rob
    >
    bruce barker, Sep 21, 2007
    #2
    1. Advertising

  3. robm

    robm Guest

    @Bruce:Thanks for your reply. I'm working to reduce the stored
    procedure calls so if this is the cause of the issue then I'm happy
    with that.

    Looking back through performance monitor logs though then the problem
    (excessive context switching) and the perceived decrease in
    performance did seem to get a lot worse after we carried out an
    upgrade from .NET 1.1 to .NET 2.0; can anyone think of any plausible
    explanation for this?

    Thanks,

    Rob


    On 21 Sep, 16:12, bruce barker <> wrote:
    > every call to the o/s is acontextswitch. every i/o interrupt is acontextswitch. as the database calls use the network, every packet is acontextswitch.
    >
    > most likely you are hitting blocking with database and thats your
    > limiting factor. you should not be doing 100's of sp calls per page
    > request, much less 1000's.
    >
    > read the chapters on set operations and joins and try to get the sql
    > calls to 10 - 50 a page request.
    >
    > -- bruce (sqlwork.com)
    >
    > robm wrote:
    > > Hi,

    >
    > > We have an ASP.NET 2 application that does some quite intensive work
    > > in order to present data to the users. A particular function gathers
    > > a lot of data from the database and as the objects are quite fine
    > > grained it makes thousands of stored procedure calls. When under no
    > > load theperformanceis fine, but when a few users use this at once
    > > then theperformancedeclines. With around 4 users executing this
    > > intensive function at once, usingperformancemonitor we see around
    > > 40% CPU usage but massive levels ofcontextswitching(~300 000/sec).
    > > I understand thatcontextswitchingincreases with the number of
    > > threads, but it doesn't seem to me that this web server is under
    > > particular load (it's a fairly well spec'd server with dual-processor,
    > > dual-core). If the CPU was maxed out I would just assume that the
    > > server couldn't cope with the load that we are putting it under, but
    > > it's not so it appears we are hitting some other server limit. Can
    > > anyone give me any pointers about what could be causing such huge
    > >contextswitchingvalues?

    >
    > > Thanks,
    > > Rob
    robm, Sep 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VS_NET_DEV
    Replies:
    2
    Views:
    3,789
    jenny
    May 25, 2004
  2. =?Utf-8?B?TWljaGFlbCBSYWN6eW5za2k=?=

    Switching Context From HTML to Code Behind

    =?Utf-8?B?TWljaGFlbCBSYWN6eW5za2k=?=, Jan 19, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    412
    tdavisjr
    Jan 19, 2006
  3. aditya

    context switching with setjmp

    aditya, Sep 22, 2004, in forum: C Programming
    Replies:
    2
    Views:
    2,335
    SM Ryan
    Sep 22, 2004
  4. Ethan
    Replies:
    5
    Views:
    1,040
    Kevin McMurtrie
    Jul 1, 2010
  5. Norah Jones
    Replies:
    0
    Views:
    67
    Norah Jones
    Apr 7, 2014
Loading...

Share This Page