Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
count events within last XX minutes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Max Bourinov  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 10:16 am
From: Max Bourinov <bouri...@gmail.com>
Date: Fri, 24 Aug 2012 18:16:51 +0400
Local: Fri, Aug 24 2012 10:16 am
Subject: [erlang-questions] count events within last XX minutes

Dear Erlangers,

Does anybody know best memory efficient way to count events within last XX
minutes?

So far I have the following idea: For each counter I have a process. The
counter process has a list of XX items. Each item represents a certain
minute, so I always know where is my current counter. There is also must be
a mechanism to remove last item from the list and add a new one. Summing
values from all items is a number of events within last XX minutes. This is
it.

Maybe there is a ready lib that does the same in a better way?

Any suggestions are welcome!

Best regards,
Max

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anders Nygren  
View profile  
 More options Aug 24 2012, 11:14 am
From: Anders Nygren <anders.nyg...@gmail.com>
Date: Fri, 24 Aug 2012 10:14:51 -0500
Local: Fri, Aug 24 2012 11:14 am
Subject: Re: [erlang-questions] count events within last XX minutes
Use an ETS table with {Counter,{YYYY,MM,DD,HH,MM}} as key, and
ets:update_counter/2,3.
update_counter returns the new counter value, so if it is 1, (or the
increment used) You know that a new minute has been entered so You can
delete the oldest.

/Anders

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Oxford  
View profile  
 More options Aug 24 2012, 4:05 pm
From: Mike Oxford <moxf...@gmail.com>
Date: Fri, 24 Aug 2012 13:05:03 -0700
Local: Fri, Aug 24 2012 4:05 pm
Subject: Re: [erlang-questions] count events within last XX minutes

If you care about, as you say, "certain minute" you can use Ulf's gproc.
 If you want "last minute" then the ETS solution below will work well, with
the modification on the Counter to use a ms/us timer like erlang:now().

-mox

On Fri, Aug 24, 2012 at 8:14 AM, Anders Nygren <anders.nyg...@gmail.com>wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Bourinov  
View profile   Translate to Translated (View Original)
 More options Aug 26 2012, 2:33 am
From: Max Bourinov <bouri...@gmail.com>
Date: Sun, 26 Aug 2012 10:33:35 +0400
Local: Sun, Aug 26 2012 2:33 am
Subject: Re: [erlang-questions] count events within last XX minutes

Hi guys,

Thank you guys for all your replies.

I think I will go with my own implementation. The only thing I cannot
understand, why you suggest using ETS for this? Why keeping data in the
state is not ok? I think on heavy load the state approach will perform
better than ETS. Moreover, I think ETS is overkill for this task.

p.s. In my case XX minutes wont exceed 120.

Best regards,
Max

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Lapshin  
View profile  
 More options Aug 26 2012, 3:22 am
From: Max Lapshin <max.laps...@gmail.com>
Date: Sun, 26 Aug 2012 11:22:19 +0400
Local: Sun, Aug 26 2012 3:22 am
Subject: Re: [erlang-questions] count events within last XX minutes

On Sun, Aug 26, 2012 at 10:33 AM, Max Bourinov <bouri...@gmail.com> wrote:
> Hi guys,

> Thank you guys for all your replies.

> I think I will go with my own implementation. The only thing I cannot
> understand, why you suggest using ETS for this?

because ets have update_counter API

> Why keeping data in the state is not ok?

because you will have giant state with all problems

>  I think on heavy load the state approach will perform
> better than ETS. Moreover, I think ETS is overkill for this task.

"overkill" here is an emotion without any exact results.
Keeping this info in state will lead to copy of growing amount of memory.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Bourinov  
View profile   Translate to Translated (View Original)
 More options Aug 26 2012, 3:54 am
From: Max Bourinov <bouri...@gmail.com>
Date: Sun, 26 Aug 2012 11:54:48 +0400
Local: Sun, Aug 26 2012 3:54 am
Subject: Re: [erlang-questions] count events within last XX minutes

Hi Max,

Thank you for you comments and explanation.

Did you saw that I need only 120 minutes? So it will be a list with 121
element at most. In this case memory won't grow at all and size of the
state will be the same.

I agree about coping but I don't understand why state will grow. Could you
please explain it?

Best regards,
Max

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Lapshin  
View profile  
 More options Aug 26 2012, 3:56 am
From: Max Lapshin <max.laps...@gmail.com>
Date: Sun, 26 Aug 2012 11:56:45 +0400
Local: Sun, Aug 26 2012 3:56 am
Subject: Re: [erlang-questions] count events within last XX minutes
with 120 minute limit, it will not grow and you can use in-state memory storage.
But ets is not an overkill. It is just another solution.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Truog  
View profile   Translate to Translated (View Original)
 More options Aug 26 2012, 4:02 am
From: Michael Truog <mjtr...@gmail.com>
Date: Sun, 26 Aug 2012 01:02:09 -0700
Local: Sun, Aug 26 2012 4:02 am
Subject: Re: [erlang-questions] count events within last XX minutes

There often is a habit with quick projects to throw data in ets, since it is easy to access the data as global data.  This helps people coming from an imperative programming background.  I don't see a good reason in the email thread that shows that ets is the best solution, simply because the amount of data is not clear.  ets can be used to limit the memory consumption, but so far, memory consumption was not mentioned as a concern.  Having an update_counter function doesn't sound too convincing because programmers are generally capable of a fetch-increment-store routine.

So, the moral of the story is to test and experiment.  You could try internal state with a dict as compared to ets, and see which make sense based on your requirements.

On 08/25/2012 11:33 PM, Max Bourinov wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Lapshin  
View profile  
 More options Aug 26 2012, 4:04 am
From: Max Lapshin <max.laps...@gmail.com>
Date: Sun, 26 Aug 2012 12:04:17 +0400
Local: Sun, Aug 26 2012 4:04 am
Subject: Re: [erlang-questions] count events within last XX minutes

On Sun, Aug 26, 2012 at 12:02 PM, Michael Truog <mjtr...@gmail.com> wrote:
> There often is a habit with quick projects to throw data in ets, since it is
> easy to access the data as global data.  This helps people coming from an
> imperative programming background.  I don't see a good reason in the email
> thread that shows that ets is the best solution,

But there is a good reason. It is performance. For example, in
erlyvideo all major statistics data are
collected not via gen_server:cal: you cannot ask process to tell its
statistics, because
it is very easy to DOS your server with such replies.

If you put stats into public ets, than collector will not be
overloaded with requests.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Bourinov  
View profile  
 More options Aug 26 2012, 4:21 am
From: Max Bourinov <bouri...@gmail.com>
Date: Sun, 26 Aug 2012 12:21:40 +0400
Local: Sun, Aug 26 2012 4:21 am
Subject: Re: [erlang-questions] count events within last XX minutes

>If you put stats into public ets, than collector will not be
>overloaded with requests.

This is interesting. I also have thoughts about avoid DOS. But I don't
understand how ETS will help here.

Here what I have. I have only one process that process clients requests. It
really doesn't make sense to have more processes because the process does
nothing but returns some pre-calculated value. If I store data in ETS my
process will have to do additional work - extracting data from ETS.

Or maybe I am missing something? Please give the right direction here. Or
maybe in my case it doesn't matter because my case is trivial?

Best regards,
Max

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gleb Peregud  
View profile  
 More options Aug 26 2012, 4:30 am
From: Gleb Peregud <glebe...@gmail.com>
Date: Sun, 26 Aug 2012 10:30:51 +0200
Local: Sun, Aug 26 2012 4:30 am
Subject: Re: [erlang-questions] count events within last XX minutes

Lately when working on project with up to a million concurrent clients
connected I had to replace few instances of central servers with a public
ets'es to avoid bottlenecks under heavy concurrent access. So choice of
data storage may depend on what are access patterns of your data - i.e. how
concurrent reads and writes are.

On Aug 26, 2012 10:22 AM, "Max Bourinov" <bouri...@gmail.com> wrote:

> >If you put stats into public ets, than collector will not be
> >overloaded with requests.

> This is interesting. I also have thoughts about avoid DOS. But I don't

understand how ETS will help here.

> Here what I have. I have only one process that process clients requests.

It really doesn't make sense to have more processes because the process
does nothing but returns some pre-calculated value. If I store data in ETS
my process will have to do additional work - extracting data from ETS.

> Or maybe I am missing something? Please give the right direction here. Or

maybe in my case it doesn't matter because my case is trivial?

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gleb Peregud  
View profile  
 More options Aug 26 2012, 4:41 am
From: Gleb Peregud <glebe...@gmail.com>
Date: Sun, 26 Aug 2012 10:41:43 +0200
Local: Sun, Aug 26 2012 4:41 am
Subject: Re: [erlang-questions] count events within last XX minutes

On Sunday, August 26, 2012, Max Bourinov wrote:

> Lately when working on project with up to a million concurrent clients
>> connected I had to replace few instances of central servers with a public
>> ets'es to avoid bottlenecks under heavy concurrent access. So choice of
>> data storage may depend on what are access patterns of your data - i.e. how
>> concurrent reads and writes are.

> That is a good point.

> I have idea how to utilize ETS in my case too: one process will write to
> ETS, and all other will read from ETS.

> The question now: will it benefit me or not?

Probably yes, if read_concurrency is enabled and you have enough concurrent
processes reading data. The best way to answer for sure is to implement
both and measure under some high load situation.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Bourinov  
View profile  
 More options Aug 26 2012, 5:02 am
From: Max Bourinov <bouri...@gmail.com>
Date: Sun, 26 Aug 2012 13:02:05 +0400
Local: Sun, Aug 26 2012 5:02 am
Subject: Re: [erlang-questions] count events within last XX minutes

Thank you!

+1 for testing :-)

Best regards,
Max

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Loïc Hoguin  
View profile   Translate to Translated (View Original)
 More options Aug 26 2012, 5:45 am
From: Loïc Hoguin <es...@ninenines.eu>
Date: Sun, 26 Aug 2012 11:45:21 +0200
Local: Sun, Aug 26 2012 5:45 am
Subject: Re: [erlang-questions] count events within last XX minutes
On 08/26/2012 10:41 AM, Gleb Peregud wrote:

If he's using update_counter then he only needs write_concurrency.
update_counter is a write operation that also returns the new value; if
you update_counter with an increment of 0, then you just happened to
read the value with a write context.

--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »