Giter VIP home page Giter VIP logo

idempotent-serverless-functions's Introduction

idempotent-serverless-functions

Examples of idempotent serverless functions

This repository demonstrates how to ensure the idempotence of serverless functions, which run on AWS Lambda using the traditional Serverless Framework. Our examples are based on the examples in the repository Serverless Examples. We add idempotence to the original functions.

What is idempotence

Idempotence means multiple invocations of a function have the same side-effect as one invocation.

Why we need idempotence

AWS Lambda uses retry to perform fault tolerance. When your function fails because of out of memory or some other reasons, it will be directly retried until it finishes successfully. For serverless functions with side-effect, retry may cause data inconsistency. For example, retrying a function purchasing a product may cause multiple deduction of money. Therefore, AWS Lambda requires programmers to write idempotent function.

idempotent-serverless-functions's People

Contributors

nsupyq avatar

Stargazers

 avatar Haochen Pan avatar

Watchers

 avatar

idempotent-serverless-functions's Issues

A question about the behavior of a function

Hi @Nsupyq,

In examples-657, you proposed to replace dynamoDbClient.put with dynamoDbClient.transactWrite because two user creation/update requests submitted in a short internal with the same userID should be recognized as duplicated requests, and thus the user should expect idempotent responses.

The idempotency key in your attempted fix is awsRequestId. If a client manually submits two requests with the same userID but different user names in a short interval, will that generate two awsRequestId's? If so, how does such an attempted fix improve the code's behavior (I guess two requests will succeed eventually, so the user first sees the userID is paired with a name and then paired with another name)?

I am learning AWS idempotency features, and please correct me if I am wrong.
Thank you and happy holidays,

Haochen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.