Laravel-Backpack / basset

Better asset helpers for Laravel apps.
MIT License
156 stars 11 forks source link

basset issues on AWS - cURL error 6: getaddrinfo() thread failed to start #141

Open Read2uk opened 2 days ago

Read2uk commented 2 days ago

Hi all,

Just checking if anyone experience the problems I am having currently (might seen some questions on the community forum).

So recently I upgraded to backpack 6 which comes with basset. Also upgraded from laravel 10 to 11 and php version from 8.1 to 8.3

I use docker to deploy application using AWS ECR which builds the ec2, I have a staging and a production environment and a load balancer.

Everything works fine on my local, as soon as I deploy to staging and production, one of these environments breaks, sometimes is staging, sometime production, Sometime I just do another deployment and things fixes by itself( without code changes)....

The error I am getting is to do with cURL error 6: getaddrinfo() thread failed to start

image

image

My thoughts are that this problem might be caused by running php artisan basset:cache on deployments which triggers too many packets per second in AWS DNS resolution?

Seen this https://repost.aws/questions/QU3jvWeM8OTCuCePQQa_WFKw/curl-error-6-getaddrinfo-thread-failed-to-start

Which says:

Amazon-provided DNS servers indeed have a limitation of 1024 packets per second for each elastic network interface. You can find here the guidance on how to troubleshoot and mitigate such issues, though it doesn't appear to be the root cause in this instance.

On a different note, several external resources [1][2] indicate that the getaddrinfo() thread failed to start error can arise due to a depleted number of available open files. As such, a potential solution could involve raising the ulimit to increase the maximum number of open files allowed by your system.

Before upgrading the application to v6 with basset, never experience problems with the application.

Please let me know if this is a known problem, not sure what to do really, I been struggling to fix it for the past week or so.

jcastroa87 commented 2 days ago

Hello @Read2uk

This sound like a server config problem.

Did you have the chance to increase limit to check if this solve the issue? Depends on how you create a Docker image, you can try with something like

RUN echo '* soft nofile 65536' >> /etc/security/limits.conf
RUN echo '* hard nofile 65536' >> /etc/security/limits.conf

Try to check the limit too ulimit -n or increase the DNS resolution limit.

Cheers.

Read2uk commented 2 days ago

Hello @jcastroa87

thanks for the reply,

Will this increase the number of opened files? RUN echo '* soft nofile 65536' >> /etc/security/limits.conf RUN echo '* hard nofile 65536' >> /etc/security/limits.conf

Are these the files when basset is running the cache?

Would you by any chance know how to increase DNS resolution limit please.

Is there any specific configuration that needs doing for basset to run in AWS?

This is my dockerfile image

`FROM php:8.3-apache

ENV APACHE_DOCUMENT_ROOT /var/www/html/public

RUN apt-get update \ && apt-get install -y \ libmcrypt-dev \ git zip \ && docker-php-ext-install pdo_mysql \ && pecl install -o -f redis \ && docker-php-ext-enable redis \ && apt-get dist-upgrade -y \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/ /usr/share/doc/ \ && apt-get clean

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/.conf RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/.conf

WORKDIR /var/www/html

COPY php.ini /usr/local/etc/php/php.ini

RUN a2enmod rewrite`

Cheers