nicolasff/phpredis — Issue #122: sometime can't connect redis 
Author: hilaowang
Created: 2012-01-23 03:03:34+00:00
State: open

I use redis->connect to connect redis server, Mostly it is ok, but sometime can't connect redis .

when I can't connect by phpredis,I find redis-cli ping or info is ok, what is possible reasons?

====
redis_version:2.2.13
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
process_id:10632
uptime_in_seconds:786850
uptime_in_days:9
lru_clock:600821
used_cpu_sys:1254.94
used_cpu_user:1151.02
used_cpu_sys_children:4398.83
used_cpu_user_children:725.32
connected_clients:31
connected_slaves:3
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:44677448
used_memory_human:42.61M
used_memory_rss:60358656
mem_fragmentation_ratio:1.35
use_tcmalloc:0
loading:0
aof_enabled:0
changes_since_last_save:4
bgsave_in_progress:0
last_save_time:1327213923
bgrewriteaof_in_progress:0
total_connections_received:291866
total_commands_processed:609798
expired_keys:36034
evicted_keys:0
keyspace_hits:337916
keyspace_misses:138085
hash_max_zipmap_entries:512
hash_max_zipmap_value:64
pubsub_channels:0
pubsub_patterns:0
vm_enabled:0
role:master
db0:keys=23057,expires=83
====

"ulimit -n" of phpredis and redis are: 32768

sysctl -a | grep tcp
sunrpc.tcp_slot_table_entries = 16
net.ipv4.tcp_slow_start_after_idle = 1
net.ipv4.tcp_dma_copybreak = 4096
net.ipv4.tcp_workaround_signed_windows = 0
net.ipv4.tcp_base_mss = 512
net.ipv4.tcp_mtu_probing = 0
net.ipv4.tcp_abc = 0
net.ipv4.tcp_congestion_control = bic
net.ipv4.tcp_tso_win_divisor = 3
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_low_latency = 0
net.ipv4.tcp_frto = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_adv_win_scale = 2
net.ipv4.tcp_app_win = 31
net.ipv4.tcp_rmem = 4096	87380	4194304
net.ipv4.tcp_wmem = 4096	16384	4194304
net.ipv4.tcp_mem = 196608	262144	393216
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_reordering = 3
net.ipv4.tcp_fack = 1
net.ipv4.tcp_orphan_retries = 0
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_stdurg = 0
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_keepalive_intvl = 75
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 7200
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_max_orphans = 65536
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_retrans_collapse = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
fs.nfs.nlm_tcpport = 0

sysctl -a | grep file
fs.file-max = 3211800