Bigtable Rowkey设计可用于实时传感器数据?

时间:2019-01-07 17:25:22

标签: bigtable google-cloud-bigtable

您的公司正在将来自工厂车间的实时传感器数据流式传输到Bigtable,他们发现性能非常差。应该如何重新设计行键以提高Bigtable在填充实时仪表板的查询上的性能?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:urn="urn:us:gov:treasury:irs:ext:aca:air:ty18" 
                  xmlns:urn1="urn:us:gov:treasury:irs:common" 
                  xmlns:urn2="urn:us:gov:treasury:irs:msg:acabusinessheader" 
                  xmlns:urn3="urn:us:gov:treasury:irs:msg:acasecurityheader" 
                  xmlns:urn4="urn:us:gov:treasury:irs:msg:irsacabulkrequesttransmitter">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
                       xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <Signature Id="SIG-E9efb6eb0a76b4277a5cf8dc3930a868d" xmlns="http://www.w3.org/2000/09/xmldsig#">
                <SignedInfo>
                    <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" />
                    <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
                    <Reference URI="#TS-E057d0d55370e45a8bc8a42f995a89aa3">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <InclusiveNamespaces PrefixList="wsse wsa soapenv urn urn1 urn2 urn3" 
                                                     xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" />
                            </Transform>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                        <DigestValue>[TIMESTAMP DIGEST VALUE]</DigestValue>
                    </Reference>
                    <Reference URI="#id-Ed6c3f891454e4eeaa73aeacaf21b6857">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <InclusiveNamespaces PrefixList="wsa soapenv urn1 urn2 urn3" 
                                                     xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" />
                            </Transform>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                        <DigestValue>[ACA BUSINESS HEADER DIGEST VALUE]</DigestValue>
                    </Reference>
                    <Reference URI="#id-Eda32be00e9954326a8dbbd30a86a975e">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <InclusiveNamespaces PrefixList="wsa soapenv urn urn1 urn3" 
                                                     xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" />
                            </Transform>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                        <DigestValue>[ACA TRANSMITTER MANIFEST DIGEST VALUE]</DigestValue>
                    </Reference>
                </SignedInfo>
                <SignatureValue>[SIGNATURE VALUE]</SignatureValue>
                <KeyInfo Id="KI-E70e6fef54fa44300bf8f732831579e03">
                    <wsse:SecurityTokenReference wsu:Id="STR-Ee23913563c7843c7917a3c63f9830d6f">
                        <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" 
                                            ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">[CERTIFICATE KEY IDENTIFIER]</wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </KeyInfo>
            </Signature>
            <wsu:Timestamp wsu:Id="TS-E057d0d55370e45a8bc8a42f995a89aa3">
                <wsu:Created>2019-01-07T16:32:54.353Z</wsu:Created>
                <wsu:Expires>2019-01-07T16:42:54.353Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
        <urn:ACATransmitterManifestReqDtl wsu:Id="id-Eda32be00e9954326a8dbbd30a86a975e" 
                                          xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            [MANIFEST DATA]
        </urn:ACATransmitterManifestReqDtl>
        <urn2:ACABusinessHeader wsu:Id="id-Ed6c3f891454e4eeaa73aeacaf21b6857" 
                                xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <urn:UniqueTransmissionId>e8d5fbcf-564d-4e31-8b48-ecc2fffe8fc0:SYS12:[TCC]::T</urn:UniqueTransmissionId>
            <urn1:Timestamp>2019-01-07T08:32:54Z</urn1:Timestamp>
        </urn2:ACABusinessHeader>
        <urn3:ACASecurityHeader>
            <urn1:UserId>[USER ID]</urn1:UserId>
        </urn3:ACASecurityHeader>
        <wsa:Action>BulkRequestTransmitterService</wsa:Action>
    </soapenv:Header>
    <soapenv:Body>
        <urn4:ACABulkRequestTransmitter version="1.0">
            <urn1:BulkExchangeFile>
                <xop:Include href="cid:1094C_Request_[TCC]_20190107T163254215Z.xml" xmlns:xop="http://www.w3.org/2004/08/xop/include" />
            </urn1:BulkExchangeFile>
        </urn4:ACABulkRequestTransmitter>
    </soapenv:Body>
</soapenv:Envelope>

根据文档,在这种情况下理想的行键是什么?我认为这应该是sensorid和timestamp的行键,但是我看到一些在线文章仅提及上述作业问题的“时间戳”。请帮忙。

关于上述特定用例,我的理论相互矛盾,如下所示: -由于按字典顺序对行进行排序,因此仅将时间戳记用作行键是不明智的。 (来自Doc-不建议将时间戳本身用作行键,因为大多数写入操作都将推送到单个节点上。) -在此用例中,由于要求是实时仪表板,因此这也可能意味着所有sensorid数据只能存储一个时间戳,因此可以仅基于时间戳进行实时查询。

请帮助使用此用例的理想行键。

2 个答案:

答案 0 :(得分:3)

问题是,它没有指定实时仪表板显示的查询,也没有对性能有太多的了解。请参考schema design for time series数据文档,其中包含一些示例方案。如果只有时间戳记为键,则可能会遇到热点问题。理想的键将是##(选项D),但是它始终取决于用例,在问题中不是很清楚。

答案 1 :(得分:0)

根据大表schema design documentation

  • “不建议将时间戳记本身用作行键,因为大多数写入操作将被推到单个节点上”。因此,这不包括选项A
  • “出于相同的原因,请避免在行键的开头放置时间戳。”。有选项C

该页面还显示“您的该数据行键可以将机器的标识符与数据的时间戳相结合(例如,machine_4223421#1425330757685)。”这导致我们选择选项D作为最佳选择。

从理论上讲,选项B也是有效的,但选项D似乎更好。