如何计算 Dynamodb 项目大小?获取验证错误 400KB Boto [英] How to calculate Dynamodb item size? Getting validationerror 400KB Boto
问题描述
ValidationException: ValidationException: 400 Bad Request{u'message': u'Item size has exceeded the maximum allowed size', u'__type': u'com.amazon.coral.validate#ValidationException'}
ValidationException: ValidationException: 400 Bad Request {u'message': u'Item size has exceeded the maximum allowed size', u'__type': u'com.amazon.coral.validate#ValidationException'}
我拥有的项目对象,大小为 92004 字节
The item object I have, has size of 92004 Bytes
>>> iii
<boto.dynamodb2.items.Item object at 0x7f7922c97190>
>>> iiip = iii.prepare_full() # it is now in dynamodb format e.g. "Item":{"time":{"N":"300"}, "user":{"S":"self"}}
>>> len(json.dumps(iiip))
92004
>>>
我得到的92004
的大小小于400KB,为什么我在保存项目时会看到上面提到的错误?
The size I get 92004
is less than 400KB, Why do I see the above mentioned error when saving the item?
任何指针?
我玩过不同大小的数据,
I played around with different sizes of data,
>>> i00['Resources'] = "A" * 66848; len(json.dumps(i00))
68481
>>> i = Item(ct.table, data=i00); i.save()
True
>>> i.delete()
True
>>> i00['Resources'] = "A" * 66849; len(json.dumps(i00))
68482
>>> i = Item(ct.table, data=i00); i.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/dynamodb2/items.py", line 455, in save
returned = self.table._put_item(final_data, expects=expects)
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/dynamodb2/table.py", line 835, in _put_item
self.connection.put_item(self.table_name, item_data, **kwargs)
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 1510, in put_item
body=json.dumps(params))
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 2842, in make_request
retry_handler=self._retry_handler)
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/connection.py", line 954, in _mexe
status = retry_handler(response, i, next_sleep)
File "/var/www/virtualenv/ken/local/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 2882, in _retry_handler
response.status, response.reason, data)
ValidationException: ValidationException: 400 Bad Request
{u'message': u'Item size has exceeded the maximum allowed size', u'__type': u'com.amazon.coral.validate#ValidationException'}
换言之,cloudtrail 数据的大小必须小于 68482 字节.我想知道为什么他们声称它是 400KB.显然,我遗漏了一些东西.
In other words, the size of cloudtrail data has to be less than 68482 bytes. I wonder why they claim it to be 400KB. Clearly, I am missing something.
推荐答案
回答我自己的问题,因为它可能会帮助遇到同样问题的人.我联系了aws技术支持,解释如下:
Answering my own question since it might help someone with the same problem. I contacted aws technical support and here is the explanation:
我的 dynamodb 表上有 5 个索引,因为 每个索引都会复制数据;总数据 = 68481 * (5 + 1) = 410886
,接近 400KB.
I had 5 indexes on my dynamodb table, since the data is replicated for each index; the total data = 68481 * (5 + 1) = 410886
which is close to 400KB.
我觉得 Dynamodb 文档中缺少这一点,如果亚马逊添加它会很好.
I feel this is missing from Dynamodb documentation and it'd be nice it amazon adds it.
因此,总而言之,最终保存在 dynamodb 表中的总数据(项目大小)为 = 实际数据 *(索引数 + 1).
So, to summarize, the total data (item size) that ends up being saved in dynamodb table is = Acutal data * (number of indexes + 1).
这篇关于如何计算 Dynamodb 项目大小?获取验证错误 400KB Boto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!