Re: Track Users Downloading

32 views
Skip to first unread message
Message has been deleted

Junlong li

unread,
May 7, 2023, 4:12:10 AM5/7/23
to openresty-en
I think tracking the number of people downloading a file for the current minute or current second is a better solution.
You can save the statistic in the shared dict in the log_by_lua_* phase.
On Monday, May 1, 2023 at 7:50:30 PM UTC+8 dania...@gmail.com wrote:
 i want to track the number of people currently downloading a file
couldnt find nginx built in option for this
can someone explain what is the best approach? i know i can track the log file, but wondering if there is another options

Reed Weichler

unread,
May 7, 2023, 5:40:26 PM5/7/23
to openre...@googlegroups.com
If you don't care about timestamps, I would just use redis for this

local redis = require 'resty.redis':new()
redis:connect('127.0.0.1', 6379)
redis:inc('download_count:'..ngx.var.request_uri)

Easy

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openresty-en/283236ab-291e-4072-a969-3b5c8584d9afn%40googlegroups.com.

Reed Weichler

unread,
May 7, 2023, 5:43:10 PM5/7/23
to openre...@googlegroups.com
Only con IMO is the added dependency

Reed Weichler

unread,
May 7, 2023, 5:44:27 PM5/7/23
to openre...@googlegroups.com
Oops sorry the code was wrong I meant to do:


local redis = require 'resty.redis':new()
redis:connect('127.0.0.1', 6379)
redis:incr('download_count:'..ngx.var.request_uri)
Reply all
Reply to author
Forward
0 new messages