I use hiredis to continuously create 3000 connections and monitor the server log,for testing。
for(int i = 0; i < 3000; i++)
{
redisContext *c = redisConnect("192.168.9.13",9876);
if(nullptr != c && 0 != c->err)
{
qDebug() << "redisContext count: "<< i << " err:"<< c->err << c->errstr;
}
redisReply *r = (redisReply*)redisCommand(c, "auth HTHC123456hthc");
if(nullptr != r)
{
qDebug() << "redisReply count: "<< i << " err:"<< r->type << r->str;
}
}
But there are still only more than 100 that can be connected,and other connections can only be suspended:
515:M 14 Jan 2021 11:50:49.187 - Accepted 192.168.9.13:1237 515:M 14 Jan 2021 11:50:49.189 - Accepted 192.168.9.13:1238 515:M 14 Jan 2021 11:50:49.191 - Accepted 192.168.9.13:1239 515:M 14 Jan 2021 11:50:49.192 - Accepted 192.168.9.13:1240 515:M 14 Jan 2021 11:50:53.326 . 124 clients connected (0 replicas), 4715952 bytes in use 515:M 14 Jan 2021 11:50:58.326 . 124 clients connected (0 replicas), 4715952 bytes in use 515:M 14 Jan 2021 11:51:03.326 . 124 clients connected (0 replicas), 4715952 bytes in use 515:M 14 Jan 2021 11:51:08.331 . 124 clients connected (0 replicas), 4715952 bytes in use 515:M 14 Jan 2021 11:51:13.331 . 124 clients connected (0 replicas), 4715952 bytes in use 515:M 14 Jan 2021 11:51:18.331 . 124 clients connected (0 replicas), 4715952 bytes in use
server:
516:C 14 Jan 2021 12:57:59.336 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 516:C 14 Jan 2021 12:57:59.337 # Redis version=6.0.6, bits=64, commit=7bf665f1, modified=0, pid=516, just started 516:C 14 Jan 2021 12:57:59.337 # Configuration loaded 516:M 14 Jan 2021 12:57:59.338 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. 516:M 14 Jan 2021 12:57:59.338 # Server can't set maximum open files to 10032 because of OS error: Too many open files. 516:M 14 Jan 2021 12:57:59.339 # Current maximum open files is 3200. maxclients has been reduced to 3168 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'. . .-
__ ''-._ _.-.. ''-. Redis 6.0.6 (7bf665f1/0) 64 bit .-.-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.-.|'_.-'| Port: 9876 |-.._ / _.-' | PID: 516-.-._-./ .-' .-' |-._-.-.__.-' _.-'_.-'| |-.-._ _.-'_.-' | http://redis.io-.-._-.__.-'.-' .-' |-._-.-.__.-' _.-'_.-'| |-.-._ _.-'_.-' |-.-._-..-'.-' .-'-._-..-' _.-'-._ _.-'-.__.-'516:M 14 Jan 2021 12:57:59.352 # Server initialized 516:M 14 Jan 2021 12:57:59.353 * Ready to accept connections 516:M 14 Jan 2021 12:57:59.353 . 0 clients connected (0 replicas), 474938 bytes in use
cli:
Server
redis_version:6.0.6 redis_git_sha1:7bf665f1 redis_git_dirty:0 redis_build_id:2d8492286bbc0e63 redis_mode:standalone os:CYGWIN_NT-10.0-18363 3.1.7-340.x86_64 x86_64 arch_bits:64 multiplexing_api:select atomicvar_api:atomic-builtin gcc_version:9.3.0 process_id:521 run_id:9946b3f38dcd3db0d378e818249cb0d02837f2c0 tcp_port:9876 uptime_in_seconds:67 uptime_in_days:0 hz:10 configured_hz:10 lru_clock:16764944 executable:/home/redis6.0.6/src/redis-server config_file:/home/redis6.0.6/src/my-redis.conf
Clients
connected_clients:124 client_recent_max_input_buffer:4 client_recent_max_output_buffer:0 blocked_clients:0 tracking_clients:0 clients_in_timeout_table:0
Memory
used_memory:4750126 used_memory_human:4.53M used_memory_rss:4715952 used_memory_rss_human:4.50M used_memory_peak:6518342 used_memory_peak_human:6.22M used_memory_peak_perc:72.87% used_memory_overhead:2581204 used_memory_startup:474938 used_memory_dataset:2168922 used_memory_dataset_perc:50.73% allocator_allocated:4715952 allocator_active:4678064 allocator_resident:4678064 total_system_memory:0 total_system_memory_human:0B used_memory_lua:37888 used_memory_lua_human:37.00K used_memory_scripts:0 used_memory_scripts_human:0B number_of_cached_scripts:0 maxmemory:0 maxmemory_human:0B maxmemory_policy:noeviction allocator_frag_ratio:0.99 allocator_frag_bytes:18446744073709513728 allocator_rss_ratio:1.00 allocator_rss_bytes:0 rss_overhead_ratio:1.01 rss_overhead_bytes:37888 mem_fragmentation_ratio:1.00 mem_fragmentation_bytes:0 mem_not_counted_for_evict:0 mem_replication_backlog:0 mem_clients_slaves:0 mem_clients_normal:2106266 mem_aof_buffer:0 mem_allocator:libc active_defrag_running:0 lazyfree_pending_objects:0
Persistence
loading:0 rdb_changes_since_last_save:0 rdb_bgsave_in_progress:0 rdb_last_save_time:1610600397 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 rdb_last_cow_size:0 aof_enabled:0 aof_rewrite_in_progress:0 aof_rewrite_scheduled:0 aof_last_rewrite_time_sec:-1 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:ok aof_last_write_status:ok aof_last_cow_size:0 module_fork_in_progress:0 module_fork_last_cow_size:0
Stats
total_connections_received:362 total_commands_processed:359 instantaneous_ops_per_sec:0 total_net_input_bytes:12561 total_net_output_bytes:20399 instantaneous_input_kbps:0.00 instantaneous_output_kbps:0.00 rejected_connections:0 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 expired_stale_perc:0.00 expired_time_cap_reached_count:0 expire_cycle_cpu_milliseconds:0 evicted_keys:0 keyspace_hits:0 keyspace_misses:0 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:0 migrate_cached_sockets:0 slave_expires_tracked_keys:0 active_defrag_hits:0 active_defrag_misses:0 active_defrag_key_hits:0 active_defrag_key_misses:0 tracking_total_keys:0 tracking_total_items:0 tracking_total_prefixes:0 unexpected_error_replies:0
Replication
role:master connected_slaves:0 master_replid:2bda7034b407afdfe4e4dc6512522ca7247aca9f master_replid2:0000000000000000000000000000000000000000 master_repl_offset:0 second_repl_offset:-1 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0
CPU
used_cpu_sys:37.718000 used_cpu_user:47.218000 used_cpu_sys_children:0.000000 used_cpu_user_children:0.000000
Modules
Cluster
cluster_enabled:0
Keyspace
Comment From: yossigo
@dearbub You should probably try to investigate what's happening on the client side, do you get some errors, what errno shows up, etc.
Please be advised that Cygwin is not a very popular or supported platform to run Redis, so for any real production use you should probably avoid it.
Comment From: heylogt
@dearbub You should probably try to investigate what's happening on the client side, do you get some errors, what
errnoshows up, etc.Please be advised that Cygwin is not a very popular or supported platform to run Redis, so for any real production use you should probably avoid it.
The client does not have any errors, except that when the number of connections reaches 124, it will suspend and wait for the server IDLE to release and reconnect.
The current latest version of Redis does not have a Windows version. If Cygwin is not recommended, is there a better official version to recommend.
Comment From: yossigo
@dearbub Redis never had official Windows support, but there are (were?) a few ports around. I think most people who do use it on Windows these days use WSL (Windows Subsystem for Linux).
Comment From: heylogt
@dearbub Redis never had official Windows support, but there are (were?) a few ports around. I think most people who do use it on Windows these days use WSL (Windows Subsystem for Linux).
My first choice and verification is to use WSL, because it can be continuously updated, but the product will eventually be used in systems including Win7, Win10, Win Server and so on, so WSL is not applicable.
Comment From: yossigo
@dearbub If that's the case you may want to look around for native Redis forks on Windows, but unfortunately I can't provide any references to that.
AFAIK Cygwin has other big limitations, such as no support for POSIX-like fork() with copy-on-write which Redis relies on for replication, snapshots and AOF rewrites. Using it for anything other than tests/development is really discouraged.
Comment From: heylogt
@dearbub If that's the case you may want to look around for native Redis forks on Windows, but unfortunately I can't provide any references to that.
AFAIK Cygwin has other big limitations, such as no support for POSIX-like
fork()with copy-on-write which Redis relies on for replication, snapshots and AOF rewrites. Using it for anything other than tests/development is really discouraged.
Thank you very much for your answer. I'll try to find a Windows solution.