Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-15 Thread envee
Hi All, Just thought I'd let you know how I went with the rate limiter. After several searches on Google about why rate limiter does not generate events at the rate I requested, I hit on the following issue on Github and saw this comment from Chris Hines about setting a burst value equal to the

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-03 Thread envee
Uli, Robert, I finally settled on using the rate limiter package to achieve what I need. I have a machine with 40 vCPUs and when I use a rate limiter with a rate limit of 1000, I am able to generate HTTP requests at that rate. (There are other processes running on this RHEL 7 machine, but it

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-03 Thread Amnon BC
> From the tests that I have performed, I can see that a Ticker pretty accurately fires at every 1ms interval. It will depend on the load on your machine. As the load on the machine increases, so with the jitter in the tick time. On Thu, Feb 3, 2022 at 1:19 AM Robert Engels wrote: > I am

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-02 Thread Robert Engels
I am unclear why you need to use an N of M. I would make sure the hardest case is handled and you can use a variety of techniques to partition the work. > On Feb 2, 2022, at 6:58 PM, envee wrote: > > And I forgot to mention that approach I mentioned talks about waking up N > goroutines at a

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-02 Thread envee
And I forgot to mention that approach I mentioned talks about waking up N goroutines at a time. The way I plan to do is to select a range of N goroutines from my list of goroutines and only allow those goroutines to send HTTP requests. I could use this approach to select the N goroutines or

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-02 Thread envee
Thanks Robert, Uli and Ian for your suggestions. I think what I will probably do is use a Ticker with a duration of 1ms. At every 1ms, I will "wake-up" N number of goroutines to trigger HTTP requests. That number N = (request rate per second / 1000) = requests per ms. So, if I need to ensure a

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-02 Thread Robert Engels
Because 2 is a magnitude larger than 2000. > On Feb 1, 2022, at 1:44 PM, Uli Kunitz wrote: > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-01 Thread Uli Kunitz
In my tests 2000 events per second appear to be fine, but there is an issue a magnitude larger with 20 000 events per second. On Tuesday, February 1, 2022 at 10:50:29 AM UTC+1 Ian Davis wrote: > On Mon, 31 Jan 2022, at 8:33 PM, Uli Kunitz wrote: > > Please have a look at golang.org/x/time/rate

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-01 Thread Ian Davis
On Mon, 31 Jan 2022, at 8:33 PM, Uli Kunitz wrote: > Please have a look at golang.org/x/time/rate > . This package should solve your > problem. > > Here is an example with 10 events per second. > > func main() { >

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Uli Kunitz
Please have a look at golang.org/x/time/rate . This package should solve your problem. Here is an example with 10 events per second. func main() { log.SetFlags(log.Lmicroseconds) l := rate.NewLimiter(10, 1) ctx :=

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Amnon
Irrespective of the language, these sort of delays are always at the mercy of the scheduling jitter of the underlying operating system. The operating system is at liberty to preempt any application at any time, and then resume it some arbitrary time later. If you ask the OS to sleep for 1ms,

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Robert Engels
Sorry for typos. Early morning on small phone with no coffee and old person eyes. :) > On Jan 31, 2022, at 7:13 AM, Robert Engels wrote: > >  > If you need a “guarantee” in these efforts it is much more complex. You must > likely need a real-time OS and interrupt driven code. A general

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Robert Engels
If you need a “guarantee” in these efforts it is much more complex. You must likely need a real-time OS and interrupt driven code. A general purpose language, os and hardware probably won’t cut it. This of it this way though, if you had 20 cpus to spread the work on, you only need to

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread envee
Thanks Kurtis and Robert. My use-case is for a telecommunications application (HTTP/2 client, 5G client to be precise) which needs to send 5G (HTTP/2) requests to a server at a configurable rate (TPS). While the telecom industry very commonly use the word TPS (Transactions Per Second), I

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread Robert Engels
Pretty much what Kurtis said. Low interval timers usually require specialized constructs if not a real time OS to efficiently (or even at all). > On Jan 30, 2022, at 9:16 PM, envee wrote: > > Thanks, but I am not sure how that reference solves the issue ? > Or are you suggesting that the

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread Kurtis Rader
On Sun, Jan 30, 2022 at 7:16 PM envee wrote: > Thanks, but I am not sure how that reference solves the issue ? > Or are you suggesting that the only way is to use Cgo and invoke usleep to > get very close to the Ticker duration specified ? > > On Monday, 31 January 2022 at 11:25:58 UTC+11

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread envee
Thanks, but I am not sure how that reference solves the issue ? Or are you suggesting that the only way is to use Cgo and invoke usleep to get very close to the Ticker duration specified ? On Monday, 31 January 2022 at 11:25:58 UTC+11 ren...@ix.netcom.com wrote: > See

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread Robert Engels
See https://github.com/golang/go/issues/27707 > On Jan 30, 2022, at 5:50 PM, envee wrote: > > Hi All, > I understand this issue has been discussed in the past, and I have seen a few > comments from Ian and Russ Cox about this topic, but I could not arrive at a > conclusion about how I can

[go-nuts] Issues when using time.Ticker microsecond duration

2022-01-30 Thread envee
Hi All, I understand this issue has been discussed in the past, and I have seen a few comments from Ian and Russ Cox about this topic, but I could not arrive at a conclusion about how I can make the time.Ticker send me ticks at atleast close to the Ticker duration I specify. At the moment, I am