When to Use Apache Derby vs. An External Database

Patrick Russell
2023-01-22 11:09

For ease of setup, Artifactory comes bundled with an internal database out of the box.

When there arefewer than 500,000 artifacts,this bundled Derby database will provide excellent performance. When Artifactory is that small, its Derby DB will perform even better than an external database such as MySQL. This is because a Derby DB runs on the same Java Virtual Machine (JVM) as Artifactory, so there is zero network latency.

However,above the 500,000 artifact threshold, performance will start to degrade. This is especially the case under very heavy load. The reason is for this degradation is the same reason for the high performance mentioned earlier. Theshared JVM resources, mainlyRAMandCPU threads, are shared between these two separate processes.

During periods of high traffic Artifactory will start to use more RAM. Yet, at the same time, the Derby database must also use more RAM to handle the influx of SQL queries Artifactory is making. This greatly increases the load on the server, and can reach a point where the Artifactory JVM exceeds its memory limits and crashes.

There are other considerations besides performance for choosing an external and out-of-process database. If your organization has its ownDataBase Administrators (DBAs),they can and should manage the Artifactory database for you. Another reason to have an external database is to makebackupseasier, you can find the details on backup best practicesHERE. The document recommends capturing adatabase snapshot, which is not possible on a Derby database.

Finally, the biggest non-performance reason to migrate to an external database is that after 500,000 artifacts, moving to another database will become increasingly difficult. As advised on the JFrog WikiHERE, the only way to change databases is to perform aSystem Export. Above 500,000 artifacts this System Export will takeabove an hour to run,which is not normally acceptable downtime.

In practically every high-scale circumstance, migrating away from the Derby database is the first recommendation by JFrog.