Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centos中,报Too many open files in system错误。 #48

Open
billsking opened this issue Oct 27, 2018 · 9 comments
Open

centos中,报Too many open files in system错误。 #48

billsking opened this issue Oct 27, 2018 · 9 comments

Comments

@billsking
Copy link

错误日志如下:
System.Net.Sockets.SocketException (23): Too many open files in system
at CSRedis.CSRedisClient.GetConnectionAndExecute[T](ConnectionPool pool, Func2 handle) at CSRedis.CSRedisClient.ExecuteScalar[T](String key, Func3 hander)
at CSRedis.CSRedisClient.Get(String key)
at RedisHelper.Get(String key)

@2881099
Copy link
Owner

2881099 commented Oct 27, 2018

https://blog.csdn.net/wangjia55/article/details/80415818
【性能优化】tomcat & Redis 优化:关于 too many open files error

@2881099
Copy link
Owner

2881099 commented Oct 27, 2018

需要配合linux参数了解错误原因。

csredis 设置连接池为多大?

@2881099
Copy link
Owner

2881099 commented Oct 27, 2018

csredis 一定要设置成单例对象在项目中使用,不需要频繁 new CSRedisClient

@billsking
Copy link
Author

我没有配置连接池,我配置的链接字符串只是ip地址加端口号,如:127.0.0.1:6379,也没有频繁new CSRedisClient,我是按照你推荐的方式使用的。如下:
var csredis = new CSRedis.CSRedisClient(null, “127.0.0.1:6379”);
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("zh-CN");
RedisHelper.Initialization(csredis, value => JsonConvert.SerializeObject(value), (data, type) => JsonConvert.DeserializeObject(data, type));
用的时候直接RedisHelper

@2881099
Copy link
Owner

2881099 commented Oct 27, 2018

CSRedisClient链接池不配置的话,默认50个。

访问量怎么样,redis-cli 观察 client list

@2881099
Copy link
Owner

2881099 commented Oct 27, 2018

这个问题终归是系统资源不够用导致的

@billsking
Copy link
Author

是的, 肯定是系统资源不够用导致的,但我open files在出现这个错误之前已经设置了10000了。而且,我那个应用秒级并发一般也就十几个。最大不会超过100个。 访问量大的问题可能不是很大。我这边会继续检查其他问题,如果您有时间的话,或者也可以试着再检查下csredis的代码。谢谢啦。

@2881099
Copy link
Owner

2881099 commented Oct 28, 2018

centos环境下有项目运行两年多,正常的。

如果允许最好升级csredis到最新版本。

@2881099
Copy link
Owner

2881099 commented Oct 28, 2018

redis-cli 观察 client list,看看有多少个链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants