STRONGLY CONSIDER OTHER ALGORITHMS than MD5

If you need deduplication: Look at murmur3-128 as it’s faster than MD5

If you need deduplication look at murmur3-128

Benchmark MD5 vs Murmur

Benchmark: guava md5-hash for string with [50000] chars

Metric(micros)(millis)
Min480.048
P50 (Median)490.049
P90500.050
P95510.051
P99540.054
P99.91430.143
Max1,6921.692
Total2,466,9092466.909
Iterations50,000

Benchmark: guava-murmur3-128bit for string with [50000] chars

Metric(micros)(millis)
Min70.007
P50 (Median)80.008
P9080.008
P9590.009
P99160.016
P99.9430.043
Max1,1821.182
Total407,266407.266
Iterations50,000

If you need cryptographic hash: look at sha-256 (as MD5 is broken for collision resistance)

Consider sha-256 if you want a greater level of collision avoidance or using it for security.

However, also note that the chance of collision with properly implemented MD5 hash is very small:

If you keep all the hashes then the probability [of collision] is a bit higher thanks to birthday paradox. To have a 50% chance of any hash colliding with any other hash you need 2^64 hashes. This means that to get a collision, on average, you’ll need to hash 6 billion files per second for 100 years. - ref