Skip to content

Considerations on Java base docker image size #155

Open
@necosta

Description

@necosta

Doing the following steps:

  1. docker pull public.ecr.aws/lambda/java:17
  2. docker run -it --entrypoint=/bin/sh public.ecr.aws/lambda/java:17
  3. cd /; du -sh

We see that this docker image has a size of 495 MB.

From AWS documentation I understand that cold starts are directly related with the size of base Java docker image so doing a further analysis on package sizes (top 10), we get:

rpm -qa --queryformat '%10{size} - %-25{name} \t %{version}\n' | sort -n | tail -10

   3639159 - bash                        4.2.46
   5395175 - dejavu-sans-fonts           2.33
   5815307 - yum                         3.4.3
   6578312 - gnupg2                      2.0.22
  12082753 - glib2                       2.56.1
  13360751 - glibc                       2.26
  14352745 - coreutils                   8.22
  25075705 - libicu                      50.2
  27436806 - python-libs                 2.7.18
 113057424 - glibc-all-langpacks         2.26

As we can see, the library that takes most space is glibc-all-langpacks (107.8 MB, 21.7% of total size)

For the majority (I guess) of lambda programs that work with default locale settings, we could replace this library with glibc-minimal-langpack (which is just a couple of KB's in size).

This would allow faster downloads and faster cold starts (when image not cached).

On https://gallery.ecr.aws/lambda/java , would you consider building an image with minimal langpack? Default image could remain with glibc-all-langpacks.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions