Skip to content

EG high memory usage #1613

@qicz

Description

@qicz

Version

the main branch

Resources Settings

limits: memory 1Gi, CPU 500m

Platform

Openshift

Description:
The current EG implementation watches a lot of resources, such as HTTPRoute, GPCRoute, EnvoyProxy, etc., and a copy of these resources will be reserved in the EG memory, causing the EG memory usage to be very high. When the user's HTTPRoute and other resources continue to increase, the memory of EG will take up more, and the user needs to adjust the resource limits dynamically ?

image

When any resource changes, EG will trigger the behavior of these changes, such as translation and infrastructure reconstruction.

// The Store is triggered even when there are no Gateways associated to the
// GatewayClass. This would happen in case the last Gateway is removed and the
// Store will be required to trigger a cleanup of envoy infra resources.
r.resources.GatewayAPIResources.Store(acceptedGC.Name, resourceTree)

func (r *Runner) subscribeAndTranslate(ctx context.Context) {
message.HandleSubscription(r.ProviderResources.GatewayAPIResources.Subscribe(ctx),
func(update message.Update[string, *gatewayapi.Resources]) {
val := update.Value
if update.Delete || val == nil {
return
}
// Translate and publish IRs.
t := &gatewayapi.Translator{
GatewayControllerName: r.Server.EnvoyGateway.Gateway.ControllerName,
GatewayClassName: v1beta1.ObjectName(update.Key),
GlobalRateLimitEnabled: r.EnvoyGateway.RateLimit != nil,
}

These are actually unnecessary. Is it possible to separate watch for related resources or separate store and subscribe when resources really change?

like this:

if val, ok := r.resources.GatewayAPIHTTPRoutesResources.Load(acceptedGC.Name); !ok || cmp.Diff(val, httpRoutes) != "" {
   r.resources.GatewayAPIHTTPRoutesResources.Store(acceptedGC.Name, httpRoutes)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions