07-31-2016 07:27 PM - edited 07-31-2016 07:28 PM
I was refering to the documentation at: http://www.cloudera.com/documentation/enterprise/latest/topics/admin_nn_memory_config.html
But, it says that the replication factor does not impact heap size on the namenode, which does not seem correct as the data structure uses about 16 bytes for each replica. The class BlockInfo has a Datanode Descriptor that maps the nodes on which the replica's of the block are present. or to be more precise block_files of a block.
So, if I have 1 million files, with each file having 2 blocks per file, the calculations will be approximately as below:
1 million files = 150 bytes x 1 million = 143.0511474609375 MB
6 millions blocks( replication 3) = (150 bytes per block + 16 bytes per replica = 150 bytes + 2 x16 = 182 bytes)x 6 million = 1041.412353515625 MB
Total = 1.15670259132385 GB
Am i correct or I am missing something ?
08-11-2016 03:48 PM
Thanks for the post, made me re-examine my assumptions based on available topics that come up on a search.
The number i had always heard is 150 bytes for every block, file, and directory.  this combined with a heavy dose of "back of the envelope" type math and a taking it all times 2 as a safety factor has worked well for me in the past for a quick estimation of the amount of jvm heap you need.
If the above is actually true then the size of the files, block size, and number of directories all matter for your raw heap needed calculations. keep in mind all of the handlers use heap as well, so this won't be 100% accurate for predicting namenode heap necessary for x many files, directories, and blocks.
If you are interested in performing an experiment to find out what it really is, not just what it is theoritically by looking at the individual methods, I think you could find this by starting a test cluster, take a heap dump, write a single file less than the block size to HDFS / with replication 1, take another heap dump, and then compare. then you can repeat the experiment each variable, (i.e. create the file in a directory, create a file bigger than 1 block, create a file with more than 1 replica).
good luck and let us all know what you find!
08-11-2016 04:26 PM - edited 08-11-2016 04:29 PM
Thanks Ben, I agree to your point on performance ascepts that there are other things we consider while calculating this and it is a rough estimate. In production there are other factor which dictate heap of namenode like handler count, how many Datanodes can send block report in a given time frame(initDelay - parameter) and few others.
Yes, I have tested that blocks, files, directories everything counts.
I brought this up for the sake of hadoop learners that the statement "replication does not impact memory on Namenode" is incorrect.
Thanks and Regards