Maxim Levkov

Results 44 comments of Maxim Levkov

I will try to make a change and post a gist for you to review, is that ok?

Following your suggestion, I've implemented mutex operation on the middleware, please see it here: https://gist.github.com/mlevkov/41094e7d536c720e2b09f617347eb1d2 Here are the performance numbers --> Before: > Statistics Avg Stdev Max > Reqs/sec 8028.24...

RLock in addition to the mutex or in place of the mutex?

I made a quick change, followed your proposed change and testing it now.

I realized that such was the case. Here is the gist: https://gist.github.com/mlevkov/9db36bed5b818e17f5e958a4dda52e3d

the above implementation performance is: ``` Statistics Avg Stdev Max Reqs/sec 7767.36 1390.96 13622.35 Latency 19.33ms 23.62ms 477.92ms Latency Distribution 50% 6.29ms 75% 11.59ms 90% 76.47ms 95% 94.72ms 99% 125.68ms...

Something like this ? ``` func (app *application) cached(duration string, handler func(w http.ResponseWriter, r *http.Request)) http.Handler { var mutex = &sync.RWMutex{} return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { mutex.RLock() defer mutex.RUnlock()...

ok, let me make that change. Here is the performance from that one: ``` Statistics Avg Stdev Max Reqs/sec 7729.11 1396.59 13176.17 Latency 19.42ms 23.34ms 475.55ms Latency Distribution 50% 6.28ms...

here is the performance feedback from the last run with change of w.Write inside the brackets: ``` Statistics Avg Stdev Max Reqs/sec 7715.70 1414.81 13246.45 Latency 19.46ms 23.57ms 349.97ms Latency...

perhaps I'm not implementing this correctly. Would you be open to making a sample that you see fit the intent correctly? Here is the code that I performs well so...