Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Codebuild containers very very SLOW

I just setup my Codebuild pipeline for PHP Symfony2 testing by phpunit.


Situation :
Some of our tests talk to a local Database (classic mysql-server)

Codebuild use our Custom Docker image that is based on php:5.6-apache
OS : Linux Alpine PHP VERSION : 5.6

We execute these steps :

  1. Pull sources
  2. Setup database (All okey no latency)
  3. Composer install (5 min)
  4. php app/console doctrine:schema:update --force
  5. php app/console broadway:event-store:schema:init
  6. Launch phpUnit.

On local environment (Docker with 6GB RAM Allow) everything is okey.
The whole process takes like 15 Minutes... perfect.


Problem :

When i launch the build on the same image on AWS-CodeBuild this is very much longer :

  1. Pull sources (Instant)
  2. Setup database (Instant)
  3. Composer install (5min)
  4. php app/console doctrine:schema:update --force(14 min)
  5. php app/console broadway:event-store:schema:init (Instant)
  6. phpUnit (Infinity CodeBuild timeout)

Hypothesis :
It seems like all php process that access to the DB is super slow.
Classic MySQL requests have a 'normal' speed...

If someone got an idea ?
Thanks for your help
@Rops42

like image 263
Rops42 Avatar asked Oct 04 '17 17:10

Rops42


People also ask

How can I speed up CodeBuild?

You can speed up subsequent builds by using local caching. This is a good option for large intermediate build artifacts because the cache is immediately available on the build host. Local caching increases build performance for: Projects with a large, monolithic source code repository.

Does AWS CodeBuild use Docker?

For Image, choose aws/codebuild/standard:4.0. Because you use this build project to build a Docker image, select Privileged. By default, Docker containers do not allow access to any devices. Privileged mode grants a build project's Docker container access to all devices.

Does CodeBuild run as root?

Currently you cannot run as a non-root user in CodeBuild, I have passed it to the team for further review. Your feedback is very much appreciated. Is this still the case? There's now a checkbox in the console...

What is CodeBuild cache?

PDFRSS. You can save time when your project builds by using a cache. A cache can store reusable pieces of your build environment and use them across multiple builds. Your build project can use one of two types of caching: Amazon S3 or local.


1 Answers

I recommend you first to confirm your hypothesis - since it could be the most likely issue - by enabling MySQL logs (Error Log, General Log, and Slow Queries Log) in your build process and analyze them during or after the build.

If you don't find anything relevant that explains the slowness in those log files, you could use something like Blackfire to profile the code in CodeBuild, and you will find what is precisely slowing down the execution.

like image 133
mathop Avatar answered Oct 19 '22 04:10

mathop