How to count a very large volume of request

Discussion in 'ASP .Net' started by Arsen V., Feb 3, 2004.

  1. Arsen V.

    Arsen V. Guest

    Hello,

    What is the best way to accomplish the following.

    1) An ASP.NET program (consiting of one file somepage.aspx) receives about
    25,000,000 requests pay day.

    2) The requests come from a limited set of IP addresses.

    3) How to count the total number of request from each IP address per day.

    SQL Server 2000 is used on the backend.

    Currently we used the following architecture:

    * Each request to somepage.aspx generates an INSERT into a LogTable1
    * There is a clustered index on the LogTable1 on the dateStamp field which
    is of the type smalldatetime
    * The dateStamp field has a default that sets it to the getdate()
    * At the end of each day at 12:01AM there is a simple query that runs and
    does a group by to count the number of requests from each IP in the given
    date range (past 24 hours). This query works great and takes only 2 minutes
    to run.

    Is there a better way to accomplish this without having to do INSERTS into
    the LogTable1 for each request?

    It would not work to have the ASP.NET program execute an UPDATE each time to
    increment the total number of request, since this would cause LOTSSS of
    locking in the database layer.

    Thanks in advance.

    Arsen
     
    Arsen V., Feb 3, 2004
    #1
    1. Advertising

  2. You could store the data in your Application Cache, and update it
    periodically to the database.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Arsen V." <> wrote in message
    news:...
    > Hello,
    >
    > What is the best way to accomplish the following.
    >
    > 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
    > 25,000,000 requests pay day.
    >
    > 2) The requests come from a limited set of IP addresses.
    >
    > 3) How to count the total number of request from each IP address per day.
    >
    > SQL Server 2000 is used on the backend.
    >
    > Currently we used the following architecture:
    >
    > * Each request to somepage.aspx generates an INSERT into a LogTable1
    > * There is a clustered index on the LogTable1 on the dateStamp field which
    > is of the type smalldatetime
    > * The dateStamp field has a default that sets it to the getdate()
    > * At the end of each day at 12:01AM there is a simple query that runs and
    > does a group by to count the number of requests from each IP in the given
    > date range (past 24 hours). This query works great and takes only 2

    minutes
    > to run.
    >
    > Is there a better way to accomplish this without having to do INSERTS into
    > the LogTable1 for each request?
    >
    > It would not work to have the ASP.NET program execute an UPDATE each time

    to
    > increment the total number of request, since this would cause LOTSSS of
    > locking in the database layer.
    >
    > Thanks in advance.
    >
    > Arsen
    >
    >
     
    Kevin Spencer, Feb 3, 2004
    #2
    1. Advertising

  3. Hi,

    What about using the IIS log file?
    you could set it in the way you need it, basically the client IP and maybe
    the time, if you configure it to update daily all you have to do at 12:01
    is run a process that read the file generated and do what you need.

    Cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "Arsen V." <> wrote in message
    news:...
    > Hello,
    >
    > What is the best way to accomplish the following.
    >
    > 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
    > 25,000,000 requests pay day.
    >
    > 2) The requests come from a limited set of IP addresses.
    >
    > 3) How to count the total number of request from each IP address per day.
    >
    > SQL Server 2000 is used on the backend.
    >
    > Currently we used the following architecture:
    >
    > * Each request to somepage.aspx generates an INSERT into a LogTable1
    > * There is a clustered index on the LogTable1 on the dateStamp field which
    > is of the type smalldatetime
    > * The dateStamp field has a default that sets it to the getdate()
    > * At the end of each day at 12:01AM there is a simple query that runs and
    > does a group by to count the number of requests from each IP in the given
    > date range (past 24 hours). This query works great and takes only 2

    minutes
    > to run.
    >
    > Is there a better way to accomplish this without having to do INSERTS into
    > the LogTable1 for each request?
    >
    > It would not work to have the ASP.NET program execute an UPDATE each time

    to
    > increment the total number of request, since this would cause LOTSSS of
    > locking in the database layer.
    >
    > Thanks in advance.
    >
    > Arsen
    >
    >
     
    Ignacio Machin \( .NET/ C# MVP \), Feb 3, 2004
    #3
  4. Arsen V.

    Arsen V. Guest

    Hi Kevin,

    Do you suggest storing the TOTALs in the Cache?

    Or storing the actual requests: date and ip

    Would there be a locking problem?

    How to do the "periodic updates" to the database from the Cache?

    Thanks,
    Arsen

    "Kevin Spencer" <> wrote in message
    news:...
    > You could store the data in your Application Cache, and update it
    > periodically to the database.
    >
    > --
    > HTH,
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "Arsen V." <> wrote in message
    > news:...
    > > Hello,
    > >
    > > What is the best way to accomplish the following.
    > >
    > > 1) An ASP.NET program (consiting of one file somepage.aspx) receives

    about
    > > 25,000,000 requests pay day.
    > >
    > > 2) The requests come from a limited set of IP addresses.
    > >
    > > 3) How to count the total number of request from each IP address per

    day.
    > >
    > > SQL Server 2000 is used on the backend.
    > >
    > > Currently we used the following architecture:
    > >
    > > * Each request to somepage.aspx generates an INSERT into a LogTable1
    > > * There is a clustered index on the LogTable1 on the dateStamp field

    which
    > > is of the type smalldatetime
    > > * The dateStamp field has a default that sets it to the getdate()
    > > * At the end of each day at 12:01AM there is a simple query that runs

    and
    > > does a group by to count the number of requests from each IP in the

    given
    > > date range (past 24 hours). This query works great and takes only 2

    > minutes
    > > to run.
    > >
    > > Is there a better way to accomplish this without having to do INSERTS

    into
    > > the LogTable1 for each request?
    > >
    > > It would not work to have the ASP.NET program execute an UPDATE each

    time
    > to
    > > increment the total number of request, since this would cause LOTSSS of
    > > locking in the database layer.
    > >
    > > Thanks in advance.
    > >
    > > Arsen
    > >
    > >

    >
    >
     
    Arsen V., Feb 3, 2004
    #4
  5. Hi Arsen,

    You could put a DataTable in the Application Cache, and add records to it
    with each Request. As for periodic updating, you could put a routine in the
    Session_OnStart Sub that checks an Application DateTime variable, and at
    certain intervals, inserts all the records from the DataTable into the
    database and clears out the DataTable.

    To be safe, you would want to add code to your Application_OnEnd sub to
    update the database if the Application stops or times out; however, with 25M
    requests per day, that might not be necessary.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Arsen V." <> wrote in message
    news:#...
    > Hi Kevin,
    >
    > Do you suggest storing the TOTALs in the Cache?
    >
    > Or storing the actual requests: date and ip
    >
    > Would there be a locking problem?
    >
    > How to do the "periodic updates" to the database from the Cache?
    >
    > Thanks,
    > Arsen
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > You could store the data in your Application Cache, and update it
    > > periodically to the database.
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "Arsen V." <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > What is the best way to accomplish the following.
    > > >
    > > > 1) An ASP.NET program (consiting of one file somepage.aspx) receives

    > about
    > > > 25,000,000 requests pay day.
    > > >
    > > > 2) The requests come from a limited set of IP addresses.
    > > >
    > > > 3) How to count the total number of request from each IP address per

    > day.
    > > >
    > > > SQL Server 2000 is used on the backend.
    > > >
    > > > Currently we used the following architecture:
    > > >
    > > > * Each request to somepage.aspx generates an INSERT into a LogTable1
    > > > * There is a clustered index on the LogTable1 on the dateStamp field

    > which
    > > > is of the type smalldatetime
    > > > * The dateStamp field has a default that sets it to the getdate()
    > > > * At the end of each day at 12:01AM there is a simple query that runs

    > and
    > > > does a group by to count the number of requests from each IP in the

    > given
    > > > date range (past 24 hours). This query works great and takes only 2

    > > minutes
    > > > to run.
    > > >
    > > > Is there a better way to accomplish this without having to do INSERTS

    > into
    > > > the LogTable1 for each request?
    > > >
    > > > It would not work to have the ASP.NET program execute an UPDATE each

    > time
    > > to
    > > > increment the total number of request, since this would cause LOTSSS

    of
    > > > locking in the database layer.
    > > >
    > > > Thanks in advance.
    > > >
    > > > Arsen
    > > >
    > > >

    > >
    > >

    >
    >
     
    Kevin Spencer, Feb 3, 2004
    #5
  6. Arsen V.

    bruce barker Guest

    what i have done is cache the last 15 minutes. the cache has the ipaddress,
    the start of the 15 min interval, pagename, and number of hits during the
    interval. as most users cluster their hits, this cuts down the number of
    inserts.

    i flush the cache every 15 minutes of when too large.

    you can then get daily or hourly stats from the db with simple queries.

    -- bruce (sqlwork.com)


    "Arsen V." <> wrote in message
    news:...
    > Hello,
    >
    > What is the best way to accomplish the following.
    >
    > 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
    > 25,000,000 requests pay day.
    >
    > 2) The requests come from a limited set of IP addresses.
    >
    > 3) How to count the total number of request from each IP address per day.
    >
    > SQL Server 2000 is used on the backend.
    >
    > Currently we used the following architecture:
    >
    > * Each request to somepage.aspx generates an INSERT into a LogTable1
    > * There is a clustered index on the LogTable1 on the dateStamp field which
    > is of the type smalldatetime
    > * The dateStamp field has a default that sets it to the getdate()
    > * At the end of each day at 12:01AM there is a simple query that runs and
    > does a group by to count the number of requests from each IP in the given
    > date range (past 24 hours). This query works great and takes only 2

    minutes
    > to run.
    >
    > Is there a better way to accomplish this without having to do INSERTS into
    > the LogTable1 for each request?
    >
    > It would not work to have the ASP.NET program execute an UPDATE each time

    to
    > increment the total number of request, since this would cause LOTSSS of
    > locking in the database layer.
    >
    > Thanks in advance.
    >
    > Arsen
    >
    >
     
    bruce barker, Feb 3, 2004
    #6
    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. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    483
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,629
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    426
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    517
    Dave Thompson
    Feb 14, 2005
  5. Curious Joe
    Replies:
    2
    Views:
    377
Loading...

Share This Page