Lambda vs GRPC vs Choreography vs HTTP / REST I always say that 80% of your code is boilerplate. Ok, it may be overkill (and it certainly is), but part of your source code, where you have invested a lot of time and effort is related to infrastructure, not functionality. What do I mean by * infrastructure *? All that is required for your code to provide the desired service. And usually this * infrastructure * code is boilerplate, ie copy and paste with some changes, for example: Protocols handling; Input formatting; Output formatting; Boilerplate but not harmless! Despite being this code is not simple and not harmless! Big problems can arise if you inadvertently make a mistake or change something. Therefore, you need to know what you are doing and to know all the technologies involved in order to avoid problems. boilerplate I estimate a developer will waste between 50% and 80% of his time and effort (and cost) concerned with infrastructure code, including study, proof of concept, and so on. To demonstrate what I am saying, and show an alternative, I decided to post this article. Signature This is a very simple example of application. A that verifies the digital signature of a text. I have already created many versions of this small component, and I will compare them here. Pojo Java It’s a very simple code indeed. Let’s look at the : main file { LambdaLogger logger = context.getLogger(); logger.log( + textAndSignature); String [] parameters = textAndSignature.split( ); String returnValue = ; returnValue = + verify(parameters[ ],parameters[ ], , , ); logger.log(returnValue); returnValue; } { resultado = ; InputStream keystoreLocation = ; (!keystorePath.equals( )) { FileInputStream fisKs = FileInputStream(keystorePath); keystoreLocation = fisKs; } { InputStream isKs = SignatureVerifier.class.getClassLoader().getResourceAsStream( ); keystoreLocation = isKs; } KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(keystoreLocation, keystorePassword.toCharArray()); java.security.cert.Certificate certificate = keystore.getCertificate(alias); PublicKey pubKey = certificate.getPublicKey(); Signature sig = Signature.getInstance( , ); sig.initVerify(pubKey); Hex hex = Hex(); [] textContent = texto.getBytes( ); sig.update(textContent); [] signature = ( []) hex.decode(hexSignature); resultado = sig.verify(signature); resultado; } String InvalidKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException, NoSuchProviderException, SignatureException, IOException, DecoderException public myHandler (String textAndSignature, Context context) throws // Comment following two lines to run locally: "received : " ":" "" "Signature is " 1 0 "*" "meucertificado" "teste001" // Comment following line to run locally: return KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InvalidKeyException, NoSuchProviderException, DecoderException, SignatureException public static boolean verify (String hexSignature, String texto, String keystorePath, String alias, String keystorePassword) throws boolean false null if "*" new else "minhakeystore.jks" "MD5withRSA" "SunRsaSign" new byte "UTF-8" byte byte return Total: ! 66 lines The method takes two strings: a text and a digital signature from it, and verifies the signature using a that I included in the project. verify() keystore Nothing could be simpler, could it? This is actually the code to make this small module available as a function [ ] (https://docs.aws.amazon.com/lambda/latest/dg/get-started-step4- optional.html). Note that there is virtually no code here. Lambda in AWS! boilerplate This is a perfect example of ! FaaS Now let’s look at other options of exposing the same code, and comparing everything. RESTful Service In this we have a RESTful version of this same service. Here, I used to create a Java application. Let’s look at the numbers of this version: repository Dropwizard JAX-RS 6 essential source files;248 lines of code; You can download the repository and test. There is even a python client for this. The essential code to verify the signature has 66 lines, this version has 248 lines! In other words, the essential code is about 26% of the lines of code in this option. This is because I greatly simplified the RESTful service! gRPC In this release, I created a and needed to create a load balancing engine using , but I will not consider this when count the lines of code, but I will have to consider the client lines of code, after all, it’s part of the infrastructure. Although it is necessary, it is not essential. You can see this version . Here are the numbers: gRPC based service Apache Zookeeper in this folder : - 426 lines of code! Server Comparing to the 66 lines of essential code, we see that the ratio has expanded a lot: only 15% represents the essential code. I didn’t even count the customer lines! Service choreograpy I implemented an example using service choreography, with asynchronous messaging and . I created a and a client, but I will only count worker lines: RabbitMQ worker 151 lines; Here the relationship has improved a lot. The essential code is 43% of the total code. How to Make a Lambda Available in Java Compile the with the command: source code mvn clean package shade: shade This will produce an that you can load into the AWS console. and go to lambda functionality: Uber jar Go to console Select and indicate which is . Then upload your : Create Role Runtime jar Finally, set up a test event: You can test your function and evaluate the results: The has everything needed to create a for AWS Lambda. And you can use another product, such as to expose your role to the world. example project uber jar API Gateway Conclusion Less code, less complexity! You can expose functions in less than 1 minute! That is the beauty of . FaaS