Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per code distribution by default #154

Open
freeseacher opened this issue Jan 16, 2019 · 5 comments
Open

Per code distribution by default #154

freeseacher opened this issue Jan 16, 2019 · 5 comments

Comments

@freeseacher
Copy link

Currently there are way to make vts export data by status code and default is to response only with grouped by first digit.
Some error codes for example 499 on load balancer is not behave them self as others in group.

@Frodox
Copy link

Frodox commented Jul 4, 2019

Ping @vozlt ? Highly needed feature :(

@wpjunior
Copy link

wpjunior commented Mar 4, 2025

@vozl, @freeseacher, @Frodox, @u5surf, @u5surf I am willing to implement this, but I have doubts about how to store the counter for status codes ranging from 100 to 599.

Option 1: Store as a sequential array in memory

  • Pros: Requires allocation only at startup.
  • Cons: Potential memory waste—4000 bytes per node, with many empty counters to skip during the read phase.

Option 2: Store in an rbtree (Red-Black Tree)

  • Pros: Uses less memory, faster reads.
  • Cons: Requires a mutex for allocation, which may slow down writes.

Option 1.2: Allow users to specify, via a directive, the status codes they want to measure

  • Pros: Reduces memory usage. For example, with the 30 most common status codes, we can easily configure:
vhost_traffic_status_measure_status_codes 
    100 101
    200 201 202 204
    301 302 303 304 307 308
    400 401 403 404 405 406 408 409 410 413 415 429
    500 501 502 503 504 505;
  • Cons: Other status codes may be missed and not measured.

@u5surf
Copy link
Collaborator

u5surf commented Mar 4, 2025

@wpjunior

Thanks some suggestions. In personally I consider that counters are favourous to be more elaborate that you told. On the other hand, user often have handreds or thousands more incredible number of virtual hosts. Their counter nodes and also their upstream counter nodes contain in the rbtree on this module. To be more extend counter accuracy, it has to allocate more memory per a node anyway.
To keep their backward compatiblity and performance, we should prepair completely different counter node from ngx_vhost_traffic_status_node_t, user can select which to use for what is suitable for their verious usecases.

In short, we consider that it is necessary to accept their cost, complexity, the trade off their computer resources and provide them
to make it clear and without misunderstanding for their usecases to maintain this feature.

We feel like it's more complicated than making just a feature or an enhancement.

Ofcource, we are affirmative to your contribution that can be a suitable solution for their background hidden issues.

@wpjunior
Copy link

wpjunior commented Mar 4, 2025

Thanks @u5surf I am crafting the idea here: #317

@wpjunior
Copy link

wpjunior commented Mar 4, 2025

@u5surf I designed it to fit many scenarios:

  • Users with hundreds of server blocks can reduce memory consumption by specifying the desired status codes, e.g.:

    vhost_traffic_status_measure_status_codes 200 204 401 403 404 500 502 503 504;
  • Users with fewer server blocks may use:

    vhost_traffic_status_measure_status_codes all;

Please review my code. I'm a bit out of practice with C programming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants