[SUPPORT] Hudi is increasing the storage size big time
Hi, I wanted to understand how much storage overhead hudi is going to add because of its metadata. So I ran a spike with 14GB of raw data and processed it to produce a parquet files. I already have a pyspark script that does this processing without hudi. When I processed the data using the normal pyspark script it produced just one file ( Since all the data belonged to one partition ) of size 294MB snappy compressed. I replicated the same processing logic with hudi in place with the below configurations
hudi_options = { 'hoodie.table.Name': tableName, 'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator', 'hoodie.datasource.write.recordkey.field': 'sourceId,sourceAssetId,timestamp,sourceSignalId,aggregation', 'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE', 'hoodie.datasource.write.partitionpath.field': 'date,sourceId', 'hoodie.datasource.write.hive_style_partitioning': True, 'hoodie.datasource.write.table.Name': tableName, 'hoodie.datasource.write.operation': 'insert', 'hoodie.parquet.compression.codec': 'snappy', 'hoodie.parquet.compression.ratio': '0.95', 'hoodie.parquet.small.file.limit': '536870912', 'hoodie.parquet.max.file.size': '1073741824', 'hoodie.parquet.block.size': '1073741824', 'hoodie.copyonwrite.record.size.estimate': '36', 'hoodie.cleaner.commits.retained': 1, 'hoodie.combine.before.insert': True, 'hoodie.datasource.write.precombine.field': 'quality', 'hoodie.insert.shuffle.parallelism': 10, 'hoodie.datasource.write.insert.drop.duplicates': True }
But hudi produced 3 files of 815MB totalling to 2.4GB for the same partition. In both the cases I've got 72107388 records to be precise. I expected to see increase in total size but this is almost 8 times bigger in size. So that's kind of a problem. Can I get a confirmation as to are we expected to see this big a difference if hudi is used or this could be reduced further by tuning the config ?
Environment Description
-
Hudi version : 0.6.0
-
Spark version : 2.4.3
-
Hadoop version : 2.8.5-amzn-1
-
Storage (HDFS/S3/GCS..) : S3
-
Running on Docker? (yes/no) : No. Running on AWS Glue
In this case, you are using complex key combining 5 columns. From what I have seen with user deployments, this is very unusual (most common case being 1 or 2 columns). Having materialized record key has its benefits.
That being said, this could be because the individual columns themselves would have been highly compressible but not the concatenation of them. The other factor being what is the proportion of columns that constitute a record key. You can try using parquet tools to see column/block level stats on both parquet and hudi files to get more insights.
BTW, if you have noticed the dev@ , user@ community emails, there is work happening on making the record_key virtual.
@bvaradar Thank you for responding. We are using those 5 fields because that's how we can identify a unique record in our dataset. I did inspect the parquet file produced by hudi and I can see hoodie recordkey field takes up most of the memory while the other hudi meta data fields adds up to the memory.
Total Size of the file is 700MB out of which actual data is around 250MB and the rest of the memory goes for hudi meta data. Especially the hoodie record key itself amounts to 350MB in our case.
I did notice the community emails around the record_key being virtual. When can we expect that to be released ? Meanwhile is there any workaround for this issue ?
@n3nash @modi95 : Can you comment on the timelines.
@KarthickAN : Honestly, this was not raised as a major issue until recently. Having a materialized record key allows you to standardize on data model.
If I were to try improve the compression, I would try to change the ordering of the keys such that low cardinality columns is in the prefix(currently - 'sourceId,sourceAssetId,timestamp,sourceSignalId,aggregation' ) to see if compression gets better. Also, we have seen gzip compression (default for hudi) outperforming snappy in compression size.
@bvaradar will that be part of the 0.6.1 release planned sometime soon ? Is there any way we can customize it by ourselves ?
For some reason we are sticking to the snappy compression for now. I tried changing the order of the columns and it did change the compression ratio but its not much significant. We are still seeing 5.5x times increase in size approximately.
@KarthickAN Making hoodie_record_key virtual is actively being worked on. There will be an initial implementation in the next few weeks and you might be able to try it out as an WIP feature. @modi95 can you add more details on your progress here please ?
@modi95 : Can you look at this when you get a chance.
@bvaradar We have two types of data for which we have used hudi. Both of them are pretty much similar with some difference in the schema. I almost completed development. For one of the data type where we have less volume of data this difference was so huge.
Say I have following number of objects in json lines format 4326 Objects - 580.4 MB
when transformed to hudi with snappy compression enabled it comes to 4599 Objects - 7.2 GB
which is really huge. For the other type where we have more volume of data I don't see this issue. It looks like below.
json lines 6895 Objects - 100.0 GB
parquet snappy with hudi 10597 Objects - 42.4 GB
Following are the configs I am using right now.
SmallFileSize = 104857600 MaxFileSize = 125829120 RecordSize = 35 CompressionRatio = 5 InsertSplitSize = 3500000 IndexBloomNumEntries = 1500000 KeyGenClass = org.apache.hudi.keygen.ComplexKeyGenerator RecordKeyFields = sourceid,sourceassetid,sourceeventid,value,timestamp TableType = COPY_ON_WRITE PartitionPathFields = date,sourceid HiveStylePartitioning = True WriteOperation = insert CompressionCodec = snappy CommitsRetained = 1 CombineBeforeInsert = True PrecombineField = timestamp InsertDropDuplicates = True InsertShuffleParallelism = 100
Anything I should look at to improve this right now ?
THis looks fine to me. Just wondering instead of default implementation of ComplexKeyGenerator which concatenates all the fields, can you try implementing a key-generator which generates md5/sha checkums to study the behavior. Assuming the original length of the record key is large and there is pattern to exploit compression, the checksum approach could perform better. Also, see if you can try gzip as opposed to snappy.
@KarthickAN : did you get a chance to try out the suggestion from Balaji. please do update the issue w/ any updates. If the issue is resolved, feel free to close it out.
JIRA for making the key virtual -> https://issues.apache.org/jira/browse/HUDI-1449. This will be done in the next 2 months. (by next release) Closing this ticket.