• Skip to main content
  • Skip to footer

InRhythm

Your partners in accelerated digital transformation

  • Who We Are
  • Our Work
  • Our Culture
  • Events
  • Testimonials
  • Blog
  • Contact Us

Sandro Pasquali

Sep 11 2018

Learning and Growth Newsletter: September 10th

At InRhythm we’re focused on growth—for our consultants, our clients, and anyone else looking to learn. This is the first installment of a bi-weekly newsletter that will showcase the cutting-edge technologies and techniques our people are working with. Each issue will include articles written by InRhythm engineers and curated links to articles and other resources you can use to learn and grow.

This week’s theme is “serverless” technologies. It’s been a hot topic for a number of reasons—serverless tech brings new possibilities for logistical freedom and flexibility, and continued growth in the industry is a sign that it’s well on its way to becoming a ubiquitous tool for infrastructure and development. Our own Christian De Armond introduces the exciting “Zeit Now” product, and I’ll be taking you on a quick tour of how to use the Claudia.js library to power Lambda functions on AWS. I hope you like it; I’m looking forward to hearing from those interested in contributing!

Sandro Pasquali
Web Practice Lead, InRhythm

Global Serverless Deployments in Zeit Now InRhythm.com
“Christian De Armond offers a quick, easy to follow test case on Zeit Now’s straightforward, incredibly simple functionality allows for testing and sharability that can save you from wasting days on frustrating deployment issues.”

The Lamb(da) Lies Down on Broadway InRhythm.com
“To alleviate the hassle of writing tricky boilerplate code to connect with AWS Lambda, the NodeJS community has delivered several excellent “serverless toolkits” as npm packages. We’ll be using one—claudia.js—to demonstrate the ease of serverless deployment.”

Serverless Docker Beta Zeit
“The Now cloud platform now offers Serverless Docker Deployments. Learn more about implementing with Node.js, Serverless Go + Websockets, Serverless Rust, and Automatic Horizontal Scalability with easy to follow examples.”

Time Slice and Suspense API – What’s Coming in React 17? Pusher
“React 17 brings two new APIs—”Time Slice” and “Suspense”—aimed at addressing concerns over how network speed affects the loading state of an application and state is managed on low-end devices.  Time slicing can handle CPU scheduling tasks under the hood without any considerations. Suspense solves all async race conditions in one stroke. Both offer improvements that make life easier for React developers.”

Serverless Architectures Martin Fowler
“As a hot topic that the “Big Three” cloud vendors continue to invest in, it’s worth learning (or brushing up on) the basics of Serverless Computing. Read about examples and explanations of BaaS “Backend as a Service” and FaaS “Functions as a Service” architectures.”

The Cost of JavaScript in 2018 Medium
“Byte for byte, the most expensive part of a site is JavaScript. With varying techniques, including heavy auditing, learn to manage performance budgets and trim your JavaScript bundles.”

GraphQL Server Tutorial with Apollo Server and Express Robin Wieruch
“Learn how to create a GraphQL server with Apollo server and Express through comprehensive instruction and lots of visual aids. This tutorial covers many intricate possibilities of utilizing a GraphQL server, from token-based authentication to pagination to validation and errors with Apollo.”

For the latest InRhythm updates, including the Learning and Growth Newsletter, join our mailing list using the form below.

Written by Sandro Pasquali · Categorized: InRhythm News

Sep 10 2018

The Lamb(da) Lies Down on Broadway

The problems development teams at large companies like MasterCard or Goldman Sachs face are largely problems of scale. For example, how should an authentication system work when clients randomly connect to thousands, even hundreds of thousands of servers in unpredictable ways? How are sessions coordinated? How is a UI connected to one server notified about changes on another server? These difficulties faced by distributed system engineers have led to new strategies on how to structure large scale architectures.

The strategy of composing large systems out of small, focused, independent units has been successful for many teams migrating away from monolithic architectures. These composed architectures are commonly described as “microservice” architectures. One next step in this progression is moving distinct functionality into the cloud absent any server maintenance at all: “serverless” technology, sometimes described as “FaaS” (Functions as a Service).

Amazon Web Services (AWS) has pioneered this revolutionary idea with their “Lambda” offering.

In this article we’re going to use the claudia package for NodeJS, which is a well documented, maintained, and designed toolkit for deploying serverless products.

Scaling with Claudia and API Gateway

To alleviate for developers the hassle of writing tricky boilerplate code to connect with AWS Lambda, the NodeJS community has delivered several excellent “serverless toolkits” as npm packages. We will be using one named claudia.js (get it, cloud architects?), which you can learn more about here: https://claudiajs.com/.

To begin, you will need to create a free developer account with AWS at https://aws.amazon.com. Most AWS services have very generous free usage tiers, which you can use AWS while learning and developing without incurring any cost (within limit). With Lambda, for example, the first one million requests per month are free.

Now log in to your dashboard. Time to identify claudia as having access to your account and managing rights for the claudia user.

From the Services tab, select IAM. Claudia needs permission to communicate with your AWS account. You generally do not want to use your root account privileges in applications, which should be understood as “sub-users” of your account. AWS provides an Identity and Access Management (IAM) service to help with that. Let’s create an AWS profile with IAM full access, Lambda full access, and API.

1. Click Add User. You can use any name, but we’re going to use claudia to keep things consistent. You’re creating a new user claudia, affording this user programmatic access.
2. Next, the Permissions button. We need to attach the IAM account claudia just created to the Lambda and API Gateway services and give it administrative privileges.
3. Select Attach existing policies directly, and add the following permissions your claudia user will need to work with Lambda and API Gateway:

  • AdministratorAccess
  • AmazonAPIGatewayAdministrator
  • AWSLambdaFullAccess

Hit Review, where you should see a claudia user with the correct permissions.

Great. Click on Create User. You will be presented with your shiny new IAM credentials. Copy the provided Access key ID and Secret access key (you’ll need these later). You’re now ready to start deploying Lambda functions using claudia.

Installing claudia

To begin installing the claudia module, type the following command:

npm install claudia -g

Remember the credentials you just created for the claudia user? Time to store them in a place claudia can find. A good pattern here is to store an AWS configuration file in your home directory (on OSX, this would be /Users/<yoursystemusername>). Visit your home directory, and create a .aws/credentials file with the following contents (remember to replace with your real credentials):

[claudia]
aws_access_key_id = <YOUR_ACCESS_KEY>
aws_secret_access_key = <YOUR_ACCESS_SECRET>

Here we are indicating that claudia is the AWS profile name, using these IAM credentials. claudia will automatically grab and use these credentials to authenticate with AWS and do its magic.

Now let’s create a web-accessible HTTP endpoint that returns the string “Hello from InRhythm!”.

Creating a serverless API

Create a new directory and initialize an npm package with npm init, using any name that you’d like for the package. To work with AWS API Gateway, we’ll also need to install an extension package for claudia:

npm install claudia-api-builder

Next, add the following app.js file to this package:

const ApiBuilder = require('claudia-api-builder');
const api = new ApiBuilder();
module.exports = api;
api.get('/hello', function () {
return 'Hello from AWS!';
});

Here we attach a Lambda function to handle a GET on the /hello route. Note how natural this feels, especially to any Express users out there (anyone?). Surprisingly, we’re done! To deploy, enter the following into your terminal:

AWS_PROFILE=claudia claudia create --region us-east-1 --api-module app

The AWS_PROFILE environment variable provides the [claudia] profile identifier in the credentials file you created earlier, with a deployment region flag, –region. This starts the deployment process.

If everything goes well, your endpoint will be deployed, and information similar to the following will be returned:

{
"lambda": {
"role": "claudiaapi-executor",
"name": "claudiaapi",
"region": "us-east-1"
},
"api": {
"id": "s8r80rsu22",
"module": "app",
"url": "https://s8r80rsu22.execute-api.us-east-1.amazonaws.com/latest"
}
}

The returned URL points to our API gateway. But it’s not complete—now we need to add the additional route /hello, added earlier, resulting in the full URL:

https://s8r80rsu22.execute-api.us-east-1.amazonaws.com/latest/hello

You will see the following message:

Hello from InRhythm!

That was easy. Updating the function is just as easy. Return to the code and change the string message your function returns to something else, then run:

AWS_PROFILE=claudia claudia update

Go ahead and reload the returned endpoint in your browser and you will see the updated message.

We have satisfied the key goal of creating independent, stateless, services that can be replaced or upgraded (or downgraded) independently.

Remember that you can gain full access to the Lambda functions you create by simply returning to the AWS dashboard and visiting your Lambda services, where you have a complete “IDE” for managing your lambdas.

Be sure to read the docs at https://claudiajs.com/documentation.html. They are filled with examples to get you started building the future of software with NodeJS and claudia!

Written by Sandro Pasquali · Categorized: InRhythm News

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2

Footer

Interested in learning more?
Connect with Us
InRhythm

140 Broadway
Suite 2270
New York, NY 10005

1 800 683 7813
get@inrhythm.com

Copyright © 2021 · InRhythm on Genesis Framework · WordPress · Log in

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.

Necessary Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.