elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
5.26k stars 965 forks source link

vendor/ezimuel/ringphp/src/Exception/ConnectException.php failed to open stream: Too many open files #1244

Closed pnajithkumar closed 2 years ago

pnajithkumar commented 2 years ago

Summary of problem or feature request

Hi,

We are getting an exception randomly as follows when we perform the indexing. While checking the logs on the elastic search server not finding any error info.

."..vendor/ezimuel/ringphp/src/Exception/ConnectException.php): failed to open stream: Too many open files "

Could you please advise where could be the problem?

Thanks, Ajith

Code snippet of problem

System details

ezimuel commented 2 years ago

@pnajithkumar this can be a limit of the ubuntu environment that you are using. Every operating system only allows for a certain number of open files/handles/sockets. In Linux you can run the following commands to check this setting:

ulimit -n

You can increase this settings to 65535. If you want to test in your current session yu can just execute the command:

ulimit -n 65535

To save this as permanent change you need to edit /etc/sysctl.conf with sudo permission (in this example I use vim but you can use any editor, e.g. nano):

sudo vim /etc/sysctl.conf

and add the following line:

fs.file-max = 65535

Then run the following command to apply the change:

sudo sysctl -p

Let me know if this solved the issue, thanks!

pnajithkumar commented 2 years ago

Thank you so much for the response @ezimuel. So this limit should be added in the elastic search server OR the client from where we request for the indexing? The exception details that we are getting from client exception message.

"include(/var/www/.../vendor/ezimuel/ringphp/src/Exception/ConnectException.php): failed to open stream: Too many open files "

Thanks you.

mfn commented 2 years ago

@pnajithkumar the client, from where you perform the requests

pnajithkumar commented 2 years ago

Thank you @mfn .

ezimuel commented 2 years ago

@pnajithkumar do you solved the issue? Thanks.

pnajithkumar commented 2 years ago

@ezimuel, we did the config changes you mentioned, but the server configuration is still showing the old limit when we run the "ulimit -n". So we are still trying to find why the config not changing. Any suggestions appreciated. Thank you

ezimuel commented 2 years ago

@pnajithkumar if you execute:

sudo ulimit -n 65535

and after you execute:

ulimit -n

you still see the old value and not 65535? Maybe this discussion can help.

ezimuel commented 2 years ago

@pnajithkumar I'm closing this issue. If you need more assistance I can reopen it, thanks.