Testing Openziti Throughput Under Heavy Loading

Hi,

I modified Grafana/k6 with golang-sdk to run high traffic performance test.

When I increase the VU(amount of users to send http requests on the same time) to about 200, I got error messages like:

failed to dial: no apiSession, authentication attempt failed: error for request kNSbWTCL8: SERVER_TOO_MANY_REQUESTS: Too many requests to alter state have been issued. Please slow your request rate or try again later."

I traced some code and I guess the error comes from the rate limiter. Is there any way that I can configure this rate limiter?

Is there any advice to configure controller/router for performing such tests?
Thanks!

1 Like

There are a couple limiters. I think this one is the Auth limiter: Release v0.32.0 · openziti/ziti · GitHub

edge:
  # This section allows configurating the rate limiter for auth attempts
  authRateLimiter:
    # if disabled, no auth rate limiting with be enforced
    enabled: true
    # the smallest window size for auth attempts
    minSize: 5
    # the largest allowed window size for auth attempts
    maxSize: 250

(but there's another one that came with 1.0. see: Release v1.0.0 · openziti/ziti · GitHub)

As for advice, I'll get @plorenz to comment. I think he's done some of that sort of testing recently and probably has good insights overall anyway...

1 Like

Yes, there are three rate limiters to consider:

Auth Rate Limter

I agree with @TheLumberjack that this is likely what you are hitting.

This rate limiter exists because without it the system can enter a state where authentications get queued and take a long time to complete. The SDK then times out, waiting for the authentication and retries. The controller completes the auth, but the SDK no longer cares and the work is wasted. The rate limiter tries to ensure that we don't accept more auths than we can process before the SDK gives up on it. It can generally tell when we've hit the limit because writing the response back will fail, as the SDK has closed the connection.

You can try disabling it or bumping the max size if you think it will be helpful.

Also, we'll probably be able to remove this limiter in the future. Once users are using JWT-based authentication, which doesn't require storing anything in the DB, that will remove the primary bottleneck on auth. At that point, the rate limiter shouldn't be necessary anymore.

Example config was posted above.

Command Rate Limiter

Since model changes are serialized, we want to be sure that we're not building up a large queue of operations. If you're load testing using SDK clients, you shouldn't be hitting this. This primary comes into play when a lot of SDKs or routers are setting up terminators for hosting services at once. The routers handle this internally (including on behalf of SDKs setting up hosting), by retrying as appropriate when the controller is handling a flood of requests.

Example config

commandRateLimiter:
    enabled:   true
    maxQueued: 100

TLS Handshake Limiter

In testing we found that TLS handshakes could use all the CPU on a controller, leaving little for other work to get done. This limiter is disabled by default for now.

Example config

tls:
  handshakeTimeout: 30s
  rateLimiter:
    enabled: true
    minSize: 5
    maxSize: 250

Hope that's helpful, let me know if you've got any follow-up questions.
Paul

1 Like

Thanks for @TheLumberjack & @plorenz instant response!

Disabling Auth limiter did help me get rid of the logs I reported.
However, while testing 200 VUs, the other warning came up:

WARN[0032] failure creating Dial session to service web.endpoint  error="Post \"https://ctrl-perf.c2.test.synology.inc:1280/edge/client/v1/sessions\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)" errorType="*url.Error"

controller's log was flooding with:

[ 122.360]   ERROR ziti/controller/api.(*ResponderImpl).RespondWithProducer: {error=[http: Handler timeout] requestId=[hY9pSal1F] path=[/edge/client/v1/sessions]} could not respond, writing to response failed
[ 122.376]   ERROR ziti/controller/api.(*timeoutHandler).ServeHTTP: {url=[/edge/client/v1/sessions] method=[POST]} timeout for request hit, returning Service Unavailable 503
[ 122.384]   ERROR ziti/controller/api.(*timeoutHandler).ServeHTTP: {url=[/edge/client/v1/authenticate?method=cert] method=[POST]} timeout for request hit, returning Service Unavailable 503

Is there any timeout configuration I could try to tweak?
Not sure if the following timeouts in "options" could help?

    options:
      # idleTimeoutMs - optional, default 5000ms
      # The maximum amount of idle time in milliseconds allowed for pipelined HTTP requests. Setting this too high
      # can cause resources on the host to be consumed as clients remain connected and idle. Lowering this value
      # will cause clients to reconnect on subsequent HTTPs requests.
      idleTimeout: 5000ms  #http timeouts, new
      # readTimeoutMs - optional, default 5000ms
      # The maximum amount of time in milliseconds http servers will wait to read the first incoming requests. A higher
      # value risks consuming resources on the host with clients that are acting bad faith or suffering from high latency
      # or packet loss. A lower value can risk losing connections to high latency/packet loss clients.
      readTimeout: 5000ms
      # writeTimeoutMs - optional, default 100000ms
      # The total maximum time in milliseconds that the http server will wait for a single requests to be received and
      # responded too. A higher value can allow long-running requests to consume resources on the host. A lower value
      # can risk ending requests before the server has a chance to respond.
      writeTimeout: 100000ms
      # minTLSVersion - optional, default TLS1.2
      # The minimum version of TSL to support
      minTLSVersion: TLS1.2
      # maxTLSVersion - optional, default TLS1.3
      # The maximum version of TSL to support
      maxTLSVersion: TLS1.3

Thanks!

Updated:

Finally I realized that I should set Client.Timeout in k6's http.Client, and setting it to 30sec solved my flooding logs in test case VU=200. But It still happened in test case VU=500.
I'm wondering if I should find a way to change the Client.Timeout for golang-sdk's library? Because I think the request /edge/client/v1/sessions was sent by the sdk.

You can get to the HttpClient used to make those REST calls, but it's harder than it needs to be.

If you've got an SDK context, you can do the following:

var ctx Context = ...
client := ctx.(*ContextImpl).CtrlClt.HttpClient

We should probably add some way to tweak that explicitly.

Cheers,
Paul

1 Like

@plorenz Thank you very much for your reply!
I applied your advice to here.

Today I found a frustrated symptom.
I noticed that the result of VU=100 test result dropped from 100-rps to 20-rps, and I couldn't find the reason even if I restored all my modifications on parameters.

I also retest my control group(NGINX), which can still produce the same result like before, so I don't think the problem comes from my network or hardware environment.

Do you have any idea that controller/edge could have some 'state' persisted after a long-time test which could cause the handling rate become low?

I also noticed that after docker compose up my ziti environment, the controller seems to be busying on sth. Because it consumed about 67% of a core observed from htop. Meanwhile, the log output wasn't printing anything(maybe I should set loglevel to debug?).

Here are my configuration:
My Image version: openziti/quickstart:1.0.0-b0f91af0

controller:

v: 3

#trace:
#  path: "ctrl-perf.mydomain.inc.trace"

#profile:
#  memory:
#    path: ctrl.memprof

db:                     "/persistent/db/ctrl.db"

identity:
  cert:        "/persistent/pki/ziti-controller-intermediate/certs/ziti-controller-client.cert"
  server_cert: "/persistent/pki/ziti-controller-intermediate/certs/ziti-controller-server.chain.pem"
  key:         "/persistent/pki/ziti-controller-intermediate/keys/ziti-controller-server.key"
  ca:          "/persistent/pki/cas.pem"
  alt_server_certs:
    - server_cert:  "/etc/certs/bundle.crt"
      server_key:   "/etc/certs/mydomain.inc.key"

# Network Configuration
#
# Configure how the controller will establish and manage the overlay network, and routing operations on top of
# the network.
#
#network:

  # routeTimeoutSeconds controls the number of seconds the controller will wait for a route attempt to succeed.
  #routeTimeoutSeconds:  10

  # createCircuitRetries controls the number of retries that will be attempted to create a path (and terminate it)
  # for new circuits.
  #createCircuitRetries: 2  

  # pendingLinkTimeoutSeconds controls how long we'll wait before creating a new link between routers where
  # there isn't an established link, but a link request has been sent
  #pendingLinkTimeoutSeconds: 10

  # Defines the period that the controller re-evaluates the performance of all of the circuits
  # running on the network.
  #
  #cycleSeconds:         15
  
  # Sets router minimum cost. Defaults to 10
  #minRouterCost: 10

  # Sets how often a new control channel connection can take over for a router with an existing control channel connection
  # Defaults to 1 minute
  #routerConnectChurnLimit: 1m

  # Sets the latency of link when it's first created. Will be overwritten as soon as latency from the link is actually
  # reported from the routers. Defaults to 65 seconds.
  #initialLinkLatency: 65s
  
  #smart:
    #
    # Defines the fractional upper limit of underperforming circuits that are candidates to be re-routed. If 
    # smart routing detects 100 circuits that are underperforming, and `smart.rerouteFraction` is set to `0.02`,
    # then the upper limit of circuits that will be re-routed in this `cycleSeconds` period will be limited to 
    # 2 (2% of 100). 
    #
    #rerouteFraction:    0.02
    # 
    # Defines the hard upper limit of underperforming circuits that are candidates to be re-routed. If smart 
    # routing detects 100 circuits that are underperforming, and `smart.rerouteCap` is set to `1`, and 
    # `smart.rerouteFraction` is set to `0.02`, then the upper limit of circuits that will be re-routed in this 
    # `cycleSeconds` period will be limited to 1.
    #
    #rerouteCap:         4  

# the endpoint that routers will connect to the controller over.
ctrl:
  options:
  # (optional) settings
  # set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1)
   outQueueSize: 5000
   maxQueuedConnects: 5000
  # the maximum number of connects that have  begun hello synchronization (1 to 1000, default 16)
   maxOutstandingConnects: 1000
  # the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 5000ms)
  #connectTimeoutMs:       300000
  #writeTimeout: 300000
  listener:             tls:0.0.0.0:6262

#metrics:
#  influxdb:
#    url:                http://localhost:8086
#    database:           ziti

# xctrl_example
#
#example:
#  enabled:              false
#  delay:                5s

healthChecks:
  boltCheck:
    # How often to try entering a bolt read tx. Defaults to 30 seconds
    interval: 30s
    # When to time out the check. Defaults to 20 seconds
    timeout: 20s
    # How long to wait before starting the check. Defaults to 30 seconds
    initialDelay: 30s

# By having an 'edge' section defined, the ziti-controller will attempt to parse the edge configuration. Removing this
# section, commenting out, or altering the name of the section will cause the edge to not run.
edge:
  # This section allows configurating the rate limiter for auth attempts
  authRateLimiter:
    # if disabled, no auth rate limiting with be enforced
    enabled: false
    # the smallest window size for auth attempts
    minSize: 1000
    # the largest allowed window size for auth attempts
    maxSize: 1000
  # This section represents the configuration of the Edge API that is served over HTTPS
  api:
    #(optional, default 90s) Alters how frequently heartbeat and last activity values are persisted
    # activityUpdateInterval: 90s
    #(optional, default 250) The number of API Sessions updated for last activity per transaction
    # activityUpdateBatchSize: 250
    # sessionTimeout - optional, default 30m
    # The number of minutes before an Edge API session will time out. Timeouts are reset by
    # API requests and connections that are maintained to Edge Routers
    sessionTimeout: 30m
    # address - required
    # The default address (host:port) to use for enrollment for the Client API. This value must match one of the addresses
    # defined in this Controller.WebListener.'s bindPoints.
    address: ctrl-perf.mydomain.inc:1280
  # This section is used to define option that are used during enrollment of Edge Routers, Ziti Edge Identities.
  enrollment:
    # signingCert - required
    # A Ziti Identity configuration section that specifically makes use of the cert and key fields to define
    # a signing certificate from the PKI that the Ziti environment is using to sign certificates. The signingCert.cert
    # will be added to the /.well-known CA store that is used to bootstrap trust with the Ziti Controller.
    signingCert:
      cert: /persistent/pki/signing.pem
      key:  /persistent/pki/ziti-signing-intermediate/keys/ziti-signing-intermediate.key
    # edgeIdentity - optional
    # A section for identity enrollment specific settings
    edgeIdentity:
      # duration - optional, default 180m
      # The length of time that a Ziti Edge Identity enrollment should remain valid. After
      # this duration, the enrollment will expire and no longer be usable.
      duration: 180m
    # edgeRouter - Optional
    # A section for edge router enrollment specific settings.
    edgeRouter:
      # duration - optional, default 180m
      # The length of time that a Ziti Edge Router enrollment should remain valid. After
      # this duration, the enrollment will expire and no longer be usable.
      duration: 180m

# web
# Defines webListeners that will be hosted by the controller. Each webListener can host many APIs and be bound to many
# bind points.
web:
  # name - required
  # Provides a name for this listener, used for logging output. Not required to be unique, but is highly suggested.
  - name: client-management
    # bindPoints - required
    # One or more bind points are required. A bind point specifies an interface (interface:port string) that defines
    # where on the host machine the webListener will listen and the address (host:port) that should be used to
    # publicly address the webListener(i.e. mydomain.com, localhost, 127.0.0.1). This public address may be used for
    # incoming address resolution as well as used in responses in the API.
    bindPoints:
      #interface - required
      # A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces
      - interface: 0.0.0.0:1280
        # address - required
        # The public address that external incoming requests will be able to resolve. Used in request processing and
        # response content that requires full host:port/path addresses.
        address: ctrl-perf.mydomain.inc:1280
    # identity - optional
    # Allows the webListener to have a specific identity instead of defaulting to the root 'identity' section.
    identity:
      ca:          "/persistent/pki/ziti-edge-controller-root-ca/certs/ziti-edge-controller-root-ca.cert"
      key:         "/persistent/pki/ziti-edge-controller-intermediate/keys/ctrl-perf.mydomain.inc-server.key"
      server_cert: "/persistent/pki/ziti-edge-controller-intermediate/certs/ctrl-perf.mydomain.inc-server.chain.pem"
      cert:        "/persistent/pki/ziti-edge-controller-intermediate/certs/ctrl-perf.mydomain.inc-client.cert"
      alt_server_certs:
      - server_cert: "/etc/certs/bundle.crt"
        server_key:  "/etc/certs/mydomain.inc.key"
      
    # options - optional
    # Allows the specification of webListener level options - mainly dealing with HTTP/TLS settings. These options are
    # used for all http servers started by the current webListener.
    options:
      # idleTimeoutMs - optional, default 5000ms
      # The maximum amount of idle time in milliseconds allowed for pipelined HTTP requests. Setting this too high
      # can cause resources on the host to be consumed as clients remain connected and idle. Lowering this value
      # will cause clients to reconnect on subsequent HTTPs requests.
      idleTimeout: 5000ms  #http timeouts, new
      # readTimeoutMs - optional, default 5000ms
      # The maximum amount of time in milliseconds http servers will wait to read the first incoming requests. A higher
      # value risks consuming resources on the host with clients that are acting bad faith or suffering from high latency
      # or packet loss. A lower value can risk losing connections to high latency/packet loss clients.
      readTimeout: 5000ms
      # writeTimeoutMs - optional, default 100000ms
      # The total maximum time in milliseconds that the http server will wait for a single requests to be received and
      # responded too. A higher value can allow long-running requests to consume resources on the host. A lower value
      # can risk ending requests before the server has a chance to respond.
      writeTimeout: 100000ms
      # minTLSVersion - optional, default TLS1.2
      # The minimum version of TSL to support
      minTLSVersion: TLS1.2
      # maxTLSVersion - optional, default TLS1.3
      # The maximum version of TSL to support
      maxTLSVersion: TLS1.3
    # apis - required
    # Allows one or more APIs to be bound to this webListener
    apis:
      # binding - required
      # Specifies an API to bind to this webListener. Built-in APIs are
      #   - edge-management
      #   - edge-client
      #   - fabric-management
      - binding: edge-management
        # options - arg optional/required
        # This section is used to define values that are specified by the API they are associated with.
        # These settings are per API. The example below is for the 'edge-api' and contains both optional values and
        # required values.
        options: { }
      - binding: edge-client
        options: { }
      - binding: fabric
        options: { }

edge router:

v: 3

identity:
  cert:             "/persistent/ziti-edge-router.cert"
  server_cert:      "/persistent/ziti-edge-router.server.chain.cert"
  key:              "/persistent/ziti-edge-router.key"
  ca:               "/persistent/ziti-edge-router.cas"
  alt_server_certs:
    - server_cert:  "/etc/certs/bundle.crt"
      server_key:   "/etc/certs/mydomain.inc.key"

ctrl:
  endpoint:             tls:ziti-controller:6262

link:
  dialers:
    - binding: transport
  listeners:
    - binding:          transport
      bind:             tls:0.0.0.0:10081
      advertise:        tls:ctrl-perf.mydomain.inc:10081
      options:
        outQueueSize:   4

listeners:
# bindings of edge and tunnel requires an "edge" section below
  - binding: edge
    address: tls:0.0.0.0:8442
    options:
      advertise: ctrl-perf.mydomain.inc:8442
      connectTimeoutMs: 5000
      getSessionTimeout: 60
  - binding: tunnel
    options:
      mode: host #tproxy|host



edge:
  # This section allows configurating the rate limiter for auth attempts
  csr:
    country: US
    province: NC
    locality: Charlotte
    organization: NetFoundry
    organizationalUnit: Ziti
    sans:
      dns:
        - localhost
        - ctrl-perf.mydomain.inc
        - bfde46659dc5
      ip:
        - "127.0.0.1"


#transport:
#  ws:
#    writeTimeout: 10
#    readTimeout: 5
#    idleTimeout: 120
#    pongTimeout: 60
#    pingInterval: 54
#    handshakeTimeout: 10
#    readBufferSize: 4096
#    writeBufferSize: 4096
#    enableCompression: true
#    server_cert: /persistent/ziti-edge-router.server.chain.cert
#    key: /persistent/ziti-edge-router.key
alt_server_certs:
  - server_cert:  "/etc/certs/bundle.crt"
    server_key:   "/etc/certs/mydomain.inc.key"
forwarder:
  latencyProbeInterval: 10
  xgressDialQueueLength: 10000
  xgressDialWorkerCount: 10000
  linkDialQueueLength: 10000
  linkDialWorkerCount: 32

update:
I highly suspect why k6 launches requests with a slow pace. So I enabled k6's profiling option and got the frame view below, looks like connecting to edge router took a lot of time?:

Thanks for posting the pprof (side note: big fan of the new flame graph view in the pprof viewer) .

The SDK <-> router connections should generally happen once a session is established which uses the edge router. Once they are established, they should be persistent. So it should be a once time cost, unless you're restarting up your client for each request. Let me know how that lines up with how you're testing.

The high CPU load on the controller is interesting, would you be able to capture a pprof for that as well? The controller can be busy on restart as it's usually handling router connections, refreshing link state and establishing/validating terminators. The pprof should show us if there's something unexpected happening there.

How do things look on the 20 rps test vs the 100 rps test? Is the CPU or IO load any different on routers/controllers? How many routers do you have? Are there options for multiple paths? Are different paths being selected?

If you want to do a ziti fabric inspect stackdump -f '*' and send me the results, I can take a look and see if there's anything suspicious going on in the execution dumps. That will grab stackdumps for each controller/router with one file per process.

Cheers,
Paul

1 Like

Hi @plorenz ,
Really appreciate your reply with full of technical details and guidance! Orz

First, I would like to elaborate my testing topology, hw specs, and plan:

The blue arrow lines indicate the request flow.
The traffic between PC-2 & PC-3 is plain http.

I'm also planning to test another topology which moves openziti router to another PC. So that I can observe the CPU utilization from router & controller separately, and conclude which one is the bottleneck.

I only deployed one router & one controller on PC-2, and the PC-3's IP is configured as a host.v1 service
and set to 192.168.0.2, so I don't think it has multiple paths.

While testing VU=100 with result of 20-rps, CPU utilization of the controller & router(they are deployed together on PC-2) is about 30~40%.
I didn't clearly record the cpu utilization while achieving 100-rps, but I think it was nearly 90%.

PC-2's low cpu utilization is the reason why I suspect the requesting speed of K6 is too low.

For confirming the behavior of K6, I added a line for printing log before this line. And even I only test VU=1, my log keeps printing. So I think K6 is really launching a new http.Client every time for each request.

I think this kind of test is like simulating always receiving new requests from different clients(browsers, desktop apps, ...) for a duration.

I found that this cmd ziti fabric inspect stackdump -f '*' will cause error:

Encountered errors: (1)
        ziti-controller: error parsing regexp: missing argument to repetition operator: `*`

So I use this cmd ziti fabric inspect stackdump -f ".*" to generate stackdumps from controller & router's docker container individually:

Results: (2)
output result to: ziti-controller.stackdump
output result to: r2419PY9X.stackdump

Please download the zipped file by this link, the download request(expired in 7-day) is bind to your email(paul.lorenz@netfoundry.io), you will need to enter the OTP sent to your email.

Thank you very much indeed for your help!

Update:
I moved the ziti ctx generation part to init function, so that it should only create one ctx during the test.
As a result, the request speed increases immediately. So I guess reconstruction of ziti connection is the main reason causes low throughput?

However, after the test went about 1-min, I met this kind of error(192.168.0.2:7712 is the destination ip & port denoted as PC-3):

WARN[0096] Request Failed                                error="Get \"http://web.endpoint/get\": unable to dial service 'web.endpoint': dial failed: exceeded maximum [2] retries creating circuit [c/wiLDcNIBh]: error creating route for [s/wiLDcNIBh] on [r/r2419PY9X] (error creating route for [c/wiLDcNIBh]: dial tcp 192.168.0.2:7712: connect: cannot assign requested address)"
diff --git a/lib/netext/httpext/ziti.go b/lib/netext/httpext/ziti.go
index 220d9c39..5a33bff5 100644
--- a/lib/netext/httpext/ziti.go
+++ b/lib/netext/httpext/ziti.go
@@ -1,51 +1,60 @@
 package httpext
 
 import (
 	"context"
 	"fmt"
 	"net"
 	"net/http"
 	"os"
 	"strings"
 	"time"
 
 	"github.com/openziti/sdk-golang/ziti"
 )
 
-type ZitiDialContext struct {
-	context ziti.Context
-}
-
-func (dc *ZitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
-	service := strings.Split(addr, ":")[0] // will always get passed host:port
-	return dc.context.Dial(service)
-}
+var zitiCfg *ziti.Config
+var zitiCtx ziti.Context
 
-// GetZitiTransport returns a http.Transport that uses Ziti to dial
-func GetZitiTransport(originTransport *http.Transport) *http.Transport {
+func init() {
 	filePath := os.Getenv("ZITI_IDENTITY_FILE") //nolint: forbidigo //for dev
 	if filePath == "" {
 		panic("ZITI_IDENTITY_FILE should be set")
 	}
 
 	cfg, err := ziti.NewConfigFromFile(filePath)
 	if err != nil {
 		panic(fmt.Sprintf("err reading ziti identity file: %v", err))
 	}
-	ctx, err := ziti.NewContext(cfg)
+	zitiCfg = cfg
+	ctx, err := ziti.NewContext(zitiCfg)
 	if err != nil {
 		panic(fmt.Sprintf("err creating ziti context: %v", err))
 	}
 
 	impl, ok := ctx.(*ziti.ContextImpl)
 	if !ok {
 		panic("failed to get *ziti.ContextImpl from ziti.Context")
 	}
 	impl.CtrlClt.HttpClient.Timeout = 30 * time.Second
 
-	zitiDialContext := ZitiDialContext{context: ctx}
+	zitiCtx = ctx
+	fmt.Println("zitiCfg inited")
+}
+
+type ZitiDialContext struct {
+	context ziti.Context
+}
+
+func (dc *ZitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
+	service := strings.Split(addr, ":")[0] // will always get passed host:port
+	return dc.context.Dial(service)
+}
+
+// GetZitiTransport returns a http.Transport that uses Ziti to dial
+func GetZitiTransport(originTransport *http.Transport) *http.Transport {
+	zitiDialContext := ZitiDialContext{context: zitiCtx}
 	zitiTransport := originTransport.Clone() // copy default transport
 	zitiTransport.DialContext = zitiDialContext.Dial
 
 	return zitiTransport
 }

Best Regards,
Rick

Hi Rick,
Glad to hear the performance is better when you're not initializing a new Context for each run. I looked at the stack dumps you shared (thank you), and the cost is not just from having to re-establish connections to the edge routers. The SDK also needs to create a new api session and session for the service. I saw 40-50 goroutines queued up to write api sessions and a similar number queued to create sessions. Because db changes are single-writer, if you've got a lot of new sessions, the controller can bottleneck on this. One of the changes coming with the HA code is that both kinds of sessions won't be persisted in the DB, but with instead be bearer tokens. That will remove DB writes from the critical path for these operations. Those are the only write operations involved in SDK calls.

I looked into this dial tcp 192.168.0.2:7712: connect: cannot assign requested address error a bit.

I found this: net/http: cannot assign requested address · Issue #16012 · golang/go · GitHub which makes it sounds like an OS limit that may need to be adjusted. Let me know if that's helpful.

Cheers,
Paul

1 Like

Hi Paul,

Thank you for your reply!

According to your previous reply, I will run another test which send more requests during the lifetime of one persistent session, I think it will be more valuable for reference.

Is there a tutorial that I could learn how to analyze by using stackdumps? I googled a little bit, and I found goroutine-analyzer written by you! This tool definitely make the analyzing process far more friendly for users to read these stackdumps. But I still have no clue how to find the queued up sessions writing goroutines? In the image below, am I highlighting the right one which match with your description?

Could you use my stackdumps as an example to explain how to analyze and reach these conclusions?

Do I need to enable HA mode for using the bearer tokens? I upgraded my ziti binary to v1.1.3, but I still got many boltz updates during the test.

Thanks!

Best Regards,
Rick

Hi Rick,
You're using goroutine-analyzer the way i do, which is to load the stackdump and run 'Extract Duplicated Goroutines'. Then I look for suspicious things. SemaquireMutex is generally a red flag, because it means that there's contention. A lot of the analysis comes down to understanding the code and knowing what's expected and what's not. Looking at those mutex acquires and seeing the api session and session creates there, and knowing that bbolt is single writer, it makes sense.

By comparison, looking the router stacks, I know that each connected SDK client is going to have a pair of goroutines, a reader (rxer) and a writer (txer) for messages to/from the SDK. In addition, each active circuit is going to have 3 goroutines related to xgress, again a reader and a writer, plus one for managing retransmissions (LinkSendBuffer). So you can use those to measure the number of connected SDKs and the number of active circuits in the router.

You should be able to use bearer token sessions without running in full HA mode. You'd need to do at least the following:

  1. Add the oidc endpoint to the controller: ziti/doc/ha/overview.md at release-next · openziti/ziti · GitHub
  2. Set the HA flag in the router configuration
  3. Set the HA flag in the SDK ziti/doc/ha/dev-setup.md at release-next · openziti/ziti · GitHub

Even with that, the code is still alpha and my coworker tells me there's a bug (since fixed) in v1.1.3, which means this particular setup won't work.

Note that using OIDC based auth requires more work and more requests that the legacy authentication mechanism, but it's work that won't be bottle-necked, so you'll be CPU and network constrained instead of DB constrained.

You can also run the controller in HA mode without setting up a full cluster.

If you can reasonably re-use Contexts, though, then that would be the most efficient thing to do, regardless of auth mechanism.

If you've got other questions, either about stack traces or OIDC, let me know.
Cheers,
Paul

1 Like

Hi Paul,

According to your description, I decide to postpone the bearer token tests until the HA code get a mature version. For now I will focus on modifying k6 to reuse ziti context, I need to move the ziti context creation to a earlier time.

Thank you very much for your detailed explanation for the stackdumps analysis!

Best Regards,
Rick