From 9c7322c7ccab81370ada339b0cc32cc379f2f632 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 31 Jul 2018 23:40:19 -0700 Subject: [PATCH] add section about using 128 bit needle id --- Optimization.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Optimization.md b/Optimization.md index ba248c8..9fe9992 100644 --- a/Optimization.md +++ b/Optimization.md @@ -76,10 +76,10 @@ The file id generation is actually pretty trivial and you could use your own way A file key has 3 parts: - volume id: a volume with free spaces -- file id: a monotonously increasing and unique number +- needle id: a monotonously increasing and unique number - file cookie: a random number, you can customize it in whichever way you want -You can directly ask master server to assign a file key, and replace the file id part to your own unique id, e.g., user id. +You can directly ask master server to assign a file key, and replace the needle id part to your own unique id, e.g., user id. Also you can get each volume's free space from the server status. @@ -91,7 +91,17 @@ Once you are sure about the volume free spaces, you can use your own file ids. J The assigned file cookie can also be customized. -Customizing the file id and/or file cookie is an acceptable behavior. "strict monotonously increasing" is not necessary, but keeping file id in a "mostly" increasing order is expected in order to keep the in memory data structure efficient. +Customizing the needle id and/or file cookie is an acceptable behavior. "strict monotonously increasing" is not necessary, but keeping file id in a "mostly" increasing order is expected in order to keep the in memory data structure efficient. + +## Customize Needle Id to 128 bit + +By default, the needle id is a 64-bit number. But sometimes a 128-bit UUID is desired as a needle id. Now it is also possible to use a 128-bit number as the needle id. But you would need to build the binary with a special tag "128BitNeedleId". + +```bash +go install -tags 128BitNeedleId +``` + +Running this mode, the needle id generated from the master is still 64 bit. You are expected to replace the needle id with a hex encoded UUID without all the dash signs, "-". ## Upload large files @@ -137,4 +147,4 @@ When going to production, you will want to collect the logs. SeaweedFS uses glog ```bash weed -v=2 master weed -log_dir=. volume -``` \ No newline at end of file +```