]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: add counters for SSL cache lookups and misses
authorWilly Tarreau <w@1wt.eu>
Wed, 28 May 2014 14:47:01 +0000 (16:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 28 May 2014 14:53:04 +0000 (16:53 +0200)
One important aspect of SSL performance tuning is the cache size,
but there's no metric to know whether it's large enough or not. This
commit introduces two counters, one for the cache lookups and another
one for cache misses. These counters are reported on "show info" on
the stats socket. This way, it suffices to see the cache misses
counter constantly grow to know that a larger cache could possibly
help.

include/types/global.h
src/dumpstats.c
src/shctx.c

index fa93cbfab5a9a1578f2c1e9f80ba29c5a86a73e3..f7942b35df42870a2428cd9c18584701bc51c353 100644 (file)
@@ -98,6 +98,7 @@ struct global {
        int sps_lim, sps_max;
        int ssl_lim, ssl_max;
        int ssl_fe_keys_max, ssl_be_keys_max;
+       unsigned int shctx_lookups, shctx_misses;
        int comp_rate_lim;           /* HTTP compression rate limit */
        int maxpipes;           /* max # of pipes */
        int maxsock;            /* max # of sockets */
index 038af887ce2bc6955b7a9b35399e05b3b2714174..fcfad4a0c2b1f7b47814c84626b462304df25e3d 100644 (file)
@@ -2471,6 +2471,8 @@ static int stats_dump_info_to_buffer(struct stream_interface *si)
                     "SslFrontendSessionReuse_pct: %d\n"
                     "SslBackendKeyRate: %d\n"
                     "SslBackendMaxKeyRate: %d\n"
+                    "SslCacheLookups: %u\n"
+                    "SslCacheMisses: %u\n"
 #endif
                     "CompressBpsIn: %u\n"
                     "CompressBpsOut: %u\n"
@@ -2505,6 +2507,7 @@ static int stats_dump_info_to_buffer(struct stream_interface *si)
                     ssl_key_rate, global.ssl_fe_keys_max,
                     ssl_reuse,
                     read_freq_ctr(&global.ssl_be_keys_per_sec), global.ssl_be_keys_max,
+                    global.shctx_lookups, global.shctx_misses,
 #endif
                     read_freq_ctr(&global.comp_bps_in), read_freq_ctr(&global.comp_bps_out),
                     global.comp_rate_lim,
index f33b7ca8ed155af4ee970459818812b1471bdf0f..a22730a48b488d7d42c036fc91c7bcb9687f5456 100644 (file)
 #else
 #ifdef USE_SYSCALL_FUTEX
 #include <unistd.h>
-#ifndef u32
-#define u32 unsigned int
-#endif
 #include <linux/futex.h>
 #include <sys/syscall.h>
 #endif
 #endif
 #endif
 #include <arpa/inet.h>
-#include "ebmbtree.h"
+#include <ebmbtree.h>
+#include <types/global.h>
 #include "proto/shctx.h"
 
 struct shsess_packet_hdr {
@@ -440,6 +438,8 @@ SSL_SESSION *shctx_get_cb(SSL *ssl, unsigned char *key, int key_len, int *do_cop
        int data_len;
        SSL_SESSION *sess;
 
+       global.shctx_lookups++;
+
        /* allow the session to be freed automatically by openssl */
        *do_copy = 0;
 
@@ -458,6 +458,7 @@ SSL_SESSION *shctx_get_cb(SSL *ssl, unsigned char *key, int key_len, int *do_cop
        if (!shsess) {
                /* no session found: unlock cache and exit */
                shared_context_unlock();
+               global.shctx_misses++;
                return NULL;
        }