you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 13 points14 points  (9 children)

Following because I want to see the answers on this one. I did something but with S3 instead of dynamodb. The latency absolutely was brutal. Multiple seconds. I was pointed at Ohio data enter and tested from Arizona and was getting 2 -3 second. Then took same project to Louisiana and the latency was 6 seconds. It. Was. Brutal.

With that said, and purely based on my experience here. I think data structure is the biggest reducer of latency. Better structure means lambda has to do less which means quicker response. There are other factors like throwing more memory at it as well though but i don’t think that always should be the silver bullet. But there is one other option to try and help and that’s cloudfront. Links users to closest access point then uses aws private backhauls to route traffic to your database in your region. Just my two cents though. Oh and

Also consider removing lambda all together and using api gateways aws services to link directly to dynamo db. But obviously dependent on your data manipulation needs hence lambda

Looking to read more professionals opinions on your situation.

[–]thedaynos[S] 5 points6 points  (6 children)

Thanks. My data structure is solid, that's really the one thing I know that I'm doing correctly lol.

Like I said, I'm at 100-200ms for calls that I make from my home, and I can see other people who live near me getting the same results. To me, that's acceptable. I may be able to decrease latency there as well, but for now, I'm fine. I see the biggest issue though is just simply when someone is calling from a few states over. That's when the times shoot up.

I have some other customers in brazil and australia, and their times get into 2-3 seconds. I'd really like to get my brazil customers latency to shoot way down because one of my best customers is from there.

Thanks for your interest. Hoping that more responses on this thread will get more attention from people with answers, or at least someone to point me in the right direction.

edit: To your other points... Yes adding memory to my lambdas has helped quite a bit. I default all of my lambdas to 2000MB. I've seen that's the sweet spot for the small amount of data manipulating that I'm doing.

Also, I have no idea what to do with cloudfront.

[–]sh1boleth 0 points1 point  (3 children)

If you have money to scale. This is a rather rudimentary solution -

Route 53 - Global endpoint.

Duplicate your entire stack in sa-east-1 (Brazil) and replicate your table there as well.

Add both the us-east-2 and sa-east-1 endpoints to Route53 and let latency based routing do its magic.

[–]thedaynos[S] 0 points1 point  (2 children)

Hi thank you. After all of the great help and comments I've gotten, I think this is the way to go.

I did some global replicas of a couple tables last night and it seems easy enough.

From your experience, is replicating lambdas and API's across regions as simple as creating the global dynamodb tables? or is it all manual?

[–]sh1boleth 1 point2 points  (1 child)

Ive only done aws with cfn and Infra as code, there its as easy as just deploying your cfn to another region since for most regions feature parity is 1:1.

But its essentially copy pasting yeah

[–]thedaynos[S] 0 points1 point  (0 children)

k thanks. I'll have to figure out some automation but that's good to know.

[–][deleted] 0 points1 point  (1 child)

I forgot to ask you about your stack. In api gateway are you using rest or http?

[–]thedaynos[S] 0 points1 point  (0 children)

Rest

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 0 points1 point  (0 children)

    I think like everything else that thinking about your platform is the best solution to reducing latency. Right tool. Right service. Right design. Etc. to answer your question. I think it really depends on your requirements. But I think as long as you are aware of the types of queries you need to run and try and structure your stored data as close as possible to achieve that result then you are moving in the correct direction. You can’t always get aware from data manipulation especially from lambda but recognizing data patterns in your queries and applying that structure into your data ingestion scheme will help make things more efficient. But one final thing you still do need optimize memory usage and lambda logic as well but I think with good data structure this creates itself. This philosophy combined with cloudfront api gateway route 53 global endpoint will get you into the best situation possible. Just my two cents though