mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-30 17:05:19 +08:00
feat: 优化网站统计数据压力
This commit is contained in:
@@ -307,7 +307,7 @@ func (r *WebsiteStat) flushDetails() {
|
||||
|
||||
// cleanup 清理过期数据
|
||||
func (r *WebsiteStat) cleanup() {
|
||||
days, err := r.setting.GetInt(biz.SettingKeyWebsiteStatDays, 30)
|
||||
days, err := r.setting.GetInt(biz.SettingKeyWebsiteStatDays, 14)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1026,11 +1026,11 @@ func (s *CliService) Init(ctx context.Context, cmd *cli.Command) error {
|
||||
{Key: biz.SettingHiddenMenu, Value: "[]"},
|
||||
{Key: biz.SettingKeyScanAware, Value: "true"},
|
||||
{Key: biz.SettingKeyScanAwareDays, Value: "30"},
|
||||
{Key: biz.SettingKeyWebsiteStatDays, Value: "30"},
|
||||
{Key: biz.SettingKeyWebsiteStatDays, Value: "14"},
|
||||
{Key: biz.SettingKeyWebsiteStatErrBufMax, Value: "10000"},
|
||||
{Key: biz.SettingKeyWebsiteStatUVMaxKeys, Value: "1000000"},
|
||||
{Key: biz.SettingKeyWebsiteStatIPMaxKeys, Value: "500000"},
|
||||
{Key: biz.SettingKeyWebsiteStatDetailMaxKeys, Value: "100000"},
|
||||
{Key: biz.SettingKeyWebsiteStatDetailMaxKeys, Value: "50000"},
|
||||
{Key: biz.SettingKeyWebsiteStatBodyEnabled, Value: "true"},
|
||||
}
|
||||
if err = s.db.Create(&settings).Error; err != nil {
|
||||
|
||||
@@ -391,11 +391,11 @@ func (s *WebsiteStatService) Clear(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// GetSetting 获取统计设置
|
||||
func (s *WebsiteStatService) GetSetting(w http.ResponseWriter, r *http.Request) {
|
||||
days, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatDays, 30)
|
||||
days, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatDays, 14)
|
||||
errBufMax, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatErrBufMax, 10000)
|
||||
uvMaxKeys, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatUVMaxKeys, 1000000)
|
||||
ipMaxKeys, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatIPMaxKeys, 500000)
|
||||
detailMaxKeys, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatDetailMaxKeys, 100000)
|
||||
detailMaxKeys, _ := s.setting.GetInt(biz.SettingKeyWebsiteStatDetailMaxKeys, 50000)
|
||||
bodyEnabled, _ := s.setting.GetBool(biz.SettingKeyWebsiteStatBodyEnabled)
|
||||
Success(w, chix.M{
|
||||
"days": days,
|
||||
|
||||
@@ -20,7 +20,7 @@ type Aggregator struct {
|
||||
ErrBufMaxSize int // 错误缓冲最大条目数,默认 10000
|
||||
UVMaxKeys int // 每站每天 UV 去重 set 上限,默认 1000000
|
||||
IPMaxKeys int // 每站每天 IP 去重 set 上限,默认 500000
|
||||
DetailMaxKeys int // 详细统计(蜘蛛/客户端/IP/URI)每站每天最大条目数,默认 100000
|
||||
DetailMaxKeys int // 详细统计(蜘蛛/客户端/IP/URI)每站每天最大条目数,默认 50000
|
||||
BodyEnabled bool // 是否记录错误请求体,默认 false
|
||||
|
||||
// 实时统计(滑动窗口 60 秒)
|
||||
@@ -87,7 +87,7 @@ func NewAggregator() *Aggregator {
|
||||
ErrBufMaxSize: 10000,
|
||||
UVMaxKeys: 1000000,
|
||||
IPMaxKeys: 500000,
|
||||
DetailMaxKeys: 100000,
|
||||
DetailMaxKeys: 50000,
|
||||
BodyEnabled: false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user