Some common issues with build efficiency :
Docker file is inefficient
Make sure you're not building the same image multiple times and consider using multistage builds (see https://docs.docker.com/develop/develop-images/multistage-build/) to shrink the total image size. You should be able to reduce your images up to seven times smaller.
Too many end to end tests
Convert some of your test scenarios to either unit tests or component tests. (see https://martinfowler.com/articles/microservice-testing/) Component tests mock your service's dependencies (other API's, databases, message queues etc) and they take milliseconds on average rather than seconds or even minutes that end to end tests take. Ideally I aim to have 1 to 5 end to end tests and 5-30 component tests per microservice.
End to end tests are slow
There is not much you can do here other then getting rid of some of them, as described in the previous step. If you really stuck, and need an easier solution start from:
- Thread.Sleeps and introduce polling
- Identify the slowest dependency and convert that to a mocked alternative.
Build agents are not fast enough
Usually Docker files and end to end tests are first places to check and build agents are rarely the bottleneck. However if you've identified an issue, scale up.
No comments:
Post a Comment