TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

AWS Kinesis with Lambdas: Lessons Learned

112 pointsby omn1almost 7 years ago

10 comments

stlavaalmost 7 years ago
The post is good but just scratches the surface on running Kinesis Streams &#x2F; Lambda at scale. Here are a few additional things I found while running Kinesis as a data ingestion pipeline:<p>- Only write logs out that matter. Searching logs in cloudwatch is already a major PITA. Half the time I just scan the logs manually because search never returns. Also, the fewer println statements you have the quicker your function will be.<p>- Lambda is cheap, reporting function metrics to cloudwatch from a lambda is not. Be very careful about using this. - Having metrics from within your lambda is very helpful. We keep track of spout lag (delta of when event got to kineis and when it was read by the lambda), source lag (delta of when the event was emitted and when it was read by the lambda), number of events processed (were any dropped due to validation errors?).<p>- Avoid using the kinesis auto scaler tool. In theory it&#x27;s a great idea but in practice we found that scaling a stream with 60+ shards causes issues with api limits. (maybe this is fixed now...)<p>- Have plenty of disk space on whatever is emitting logs. You don&#x27;t want to run into the scenario where you can&#x27;t push logs to kinesis (eg throttling) and they start filling up your disks.<p>- Keep in mind that you have to balance our emitters, lambda, and your downstream targets. You don&#x27;t want too few &#x2F; too many shards. You don&#x27;t want to have 100 lambda instances hitting a service with 10 events each invocation.<p>- Lambda deployment tools are still young but find one that works for you. All of them have tradeoffs in how they are configured and how they deploy.<p>There are some good tidbits in the Q&amp;A section from my re:Invent talk [1]. Also, for anyone wanting to use lambda but not wanting to re-invent checkout Bender [2]. Note I&#x27;m the author.<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=AaRawf9vcZ4" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=AaRawf9vcZ4</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;Nextdoor&#x2F;bender" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Nextdoor&#x2F;bender</a><p>edit: formatting
评论 #17526119 未加载
评论 #17526997 未加载
dbllxralmost 7 years ago
&gt; For us, increasing the memory for a Lambda from 128 megabytes to 2.5 gigabytes gave us a huge boost.<p>&gt; The number of Lambda invocations shot up almost 40x.<p>One thing I&#x27;ve learned from talking to AWS support is that increasing memory also gets you more vCPUs per container.<p>-----<p>Serverless is great in scaling and handling bursts, but you may find it VERY difficult in terms of testing and debugging.<p>A while back I started using an open source tool called localstack[1] to mirror some AWS services locally. Despite some small discrepancies in certain APIs (which are totally expected), it&#x27;s made testing a lot easier for me. Something worth looking into if testing serverless code is causing you headaches.<p>[1]<a href="https:&#x2F;&#x2F;github.com&#x2F;localstack&#x2F;localstack" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;localstack&#x2F;localstack</a>
评论 #17539153 未加载
cagenutalmost 7 years ago
The article doesn&#x27;t appear to get into the end-destination of this data, it just says &quot;to AWS&quot;.<p>My initial thought is: restore last nights backup to another mysql instance on aws and then let it catchup on the binlog?<p>But I guess the unstated assumption is that their goal is to also transform to some other datastore.
评论 #17523794 未加载
评论 #17524845 未加载
评论 #17523743 未加载
otterleyalmost 7 years ago
I&#x27;m curious about the economics of this design. Real-time stream consumption implies that the consumer is always running, and if you need to run software 24x7, running it on EC2 instances is likely to be far cheaper than running Lambda functions continuously.
评论 #17524690 未加载
评论 #17524821 未加载
评论 #17524535 未加载
djhworldalmost 7 years ago
We used to run an architecture similar to this a few years ago, I work for a broadcaster and unfortunately it failed badly during a big event.<p>The Kinesis stream was adequately scaled, but the poller between Kinesis -&gt; Lambda just couldn&#x27;t cope. This was discovered after lots of support calls with AWS.<p>It might be better these days I don&#x27;t know, we moved to using Apache Flink + Apache Beam, which has a lot more features and allows us to do stuff like grouping by a window, aggregation etc.
sixdimensionalalmost 7 years ago
I&#x27;m not being negative about this, it&#x27;s a cool setup.<p>But just to be clear, the pattern (not marketing terms) is doing change data capture (essentially the database transaction log) to a message queue, with message&#x2F;job processors that can take any action, including writing the messages to other databases.<p>Kinesis is SQLStream underneath, which is probably why the lifetime of messages is limited - it&#x27;s not originally intended to be Kafka or a durable message queue.<p>EDIT: Note above, when SQLStream first came out it didn&#x27;t seem intended as a long term store. That was like really early on when I saw it at Strata. It looks like they made the storage engine pluggable and Kafka is an option too, so my statement above is likely incorrect.<p>Lambda is being used as a distributed message&#x2F;job processor, much like any worker process processing a queue would be scaled up.
评论 #17524116 未加载
评论 #17524883 未加载
dmlittlealmost 7 years ago
&gt; For us, increasing the memory for a Lambda from 128 megabytes to 2.5 gigabytes gave us a huge boost.<p>I thought the maximum memory limit for Lamda was 3008 MB and that you couldn&#x27;t bump this limit through a service request.<p>Anyone knows if you can request to bump the memory limit or the uncompressed deployment package limit (250 MB)?
评论 #17542548 未加载
mpdalmost 7 years ago
With so much overlap in the functionality and use cases of Kafka and Kinesis, it&#x27;s not clear why they increase their surface area by using both.<p>Is Kinesis&#x27; write latency better than it was? IIRC it wrote to 3 data centers synchronously, which led to some pretty bad performance. This was almost 2 years ago though.
评论 #17524491 未加载
评论 #17524917 未加载
sheeshkebabalmost 7 years ago
Copying a billion records screams for streaming? do you mean like a couple of hundred gigs that could be copied overnight (and maybe transformed with some script)?
评论 #17539729 未加载
abledonalmost 7 years ago
Anyone else reading this post with the trivago repetitive jingle on loop in the back of their mind? Din dan din dan dan —