Day two at re:Invent 2017 was incredibly packed, crowded, and exciting. My favorite announcement so far is the new AWS AppSync, as it aligns with one of the most promising (yet somehow controversial) design principles adopted by the serverless community: GraphQL.
If you are not familiar with GraphQL, we recently explained how to write GraphQL Apps using AWS Lambda, and hosted a webinar about the Love Story between Serverless and GraphQL. Here’s a quick look at what you need to know about AWS AppSync.
Mobile and Web App Challenges
I attended the first deep dive session on AWS AppSync, which brilliantly summarized the main technical challenges faced by most mobile and web applications:
- Authentication & user management
- Efficient network usage
- Multi-device support
- Data synchronization between devices
- Offline data access
- Real-time data streams
- Cloud data conflict detection & resolution
- Running server-side code (without managing servers)
Each of these challenges could merit its own article, but I am assuming that everyone has experienced a really bad mobile UX, and at least once from the user perspective (any implicit reference to the AWS re:Invent app is clearly unintentional). Moreover, most of these challenges are a direct consequence of how we’ve been designing RESTful interfaces for web and mobile.
If you are a web or mobile developer, GraphQL can help you solve many of these challenges, especially the ones related to network optimization, thanks to dynamic queries, and real-time data streams, thanks to GraphQL subscriptions.
How is GraphQL better than REST?
GraphQL can alleviate the pain caused by many complex problems that are pretty much unsolvable with REST only. This includes API resource relationships, reduced or customized information in API responses, dynamic query support, advanced ordering and paging, push notifications, etc.
GraphQL is basically a query language for APIs, and it makes it very easy to add an abstraction layer on top of already existing data and APIs. Plus, it’s strongly typed and can act as a self-documenting contract between client and server.
Again, if you are not familiar with the concept of GraphQL Queries, Mutations, and Subscriptions, have a read here (it gets more technical from now on!).
AWS AppSync Features & Gotchas
AWS AppSync allows you to focus on building apps instead of managing all the infrastructure needed to run GraphQL (either with or without servers).
AppSync will connect queries to AWS resources, and it provides built-in offline and real-time stream support via client-side libraries, which also come with different strategies for data conflict resolution (even custom Lambda-based implementations!). The service offers enterprise-level security features such as API keys, IAM, and Cognito User Pools support.
As with any GraphQL application, your development workflow would look like the following:
- Define your schema (queries, mutations, and subscriptions)
- Define resolvers (data sources)
- Use client tooling to fetch data via the GraphQL endpoint
AWS AppSync provides built-in support for three data sources:
- Lambda (for custom or generated fields)
Mutation Resolvers can be mapped into data sources via mapping templates (Velocity). As with API Gateway templates, they come with a few utilities such as JSON conversion, unique ID generation, etc., and ready-to-use sample templates. Based on the specific data source, templates will allow for complete customization of the backend query (e.g. DynamoDB PutItem, ElasticSearch geolocation queries, etc.).
Since you’ll spend most of the time working with the Schema Editor, I was quite happy to notice that it is quite user-friendly, and it comes with search and auto-complete capabilities.
AWS AppSync and AWS Lambda
You can use AWS Lambda to compute dynamic fields, eventually in a batch fashion. For example, imagine that your schema defines a “paid” field that needs to be fetched from a third-party payment system for each invoice. You would probably define a ComputePaid Function and a ComputePaidBatch Function.
The batch function will be automatically invoked to process the value of multiple records without incurring the N+1 problem. Of course, you could use the same Lambda Function for individual and batch processing.
AWS AppSync Pricing
AppSync will be charged based on the total number of operations and real-time updates. More detailed, real-time updates are charged based on the number of updates and the minutes of connection.
Here are the numbers:
- $4 per million Query and Data Modification Operations
- $2 per million Real-time Updates
- $0.08 per million minutes of connection to the AWS AppSync service
Please note that data transfer is charged at the EC2 data transfer rate and that real-time updates are priced per 5kb payload of data delivered (prorated). While the service is completely free during the preview phase, it will come with a free tier once it is generally available.
Also note that AppSync has no minimum fees or mandatory service usage, compared to other similar offerings such as Graphcool.
I expect that AWS AppSync will be well received by the serverless community, and it will make GraphQL much easier to adopt for many use cases.
It will be a great option for applications that need to drastically optimize data delivery, or to transparently manage many data sources under the hood. Moreover, it will also allow developers to design self-documenting APIs powered by a strong type system and a powerful set of developer tools that will simplify API evolution.
Keep in mind that AWS AppSync is still in preview, but you can start playing with it by signing up here.
I’m looking forward to playing with it myself next week, and I can’t wait to share my first results with the community. If you already use GraphQL in production, let us know what you think of AWS AppSync in the comments below!
Advantages and Disadvantages of Microservices Architecture
What are microservices? Let's start our discussion by setting a foundation of what microservices are. Microservices are a way of breaking large software projects into loosely coupled modules, which communicate with each other through simple Application Programming Interfaces (APIs). ...
Kubernetes Services: AWS vs. Azure vs. Google Cloud
Kubernetes is a popular open-source container orchestration platform that allows us to deploy and manage multi-container applications at scale. Businesses are rapidly adopting this revolutionary technology to modernize their applications. Cloud service providers — such as Amazon Web Ser...
AWS Internet of Things (IoT): The 3 Services You Need to Know
The Internet of Things (IoT) embeds technology into any physical thing to enable never-before-seen levels of connectivity. IoT is revolutionizing industries and creating many new market opportunities. Cloud services play an important role in enabling deployment of IoT solutions that min...
Which Certifications Should I Get?
As we mentioned in an earlier post, the old AWS slogan, “Cloud is the new normal” is indeed a reality today. Really, cloud has been the new normal for a while now and getting credentials has become an increasingly effective way to quickly showcase your abilities to recruiters and compan...
How to Go Serverless Like a Pro
So, no servers? Yeah, I checked and there are definitely no servers. Well...the cloud service providers do need servers to host and run the code, but we don’t have to worry about it. Which operating system to use, how and when to run the instances, the scalability, and all the arch...
AWS Security: Bastion Hosts, NAT instances and VPC Peering
Effective security requires close control over your data and resources. Bastion hosts, NAT instances, and VPC peering can help you secure your AWS infrastructure. Welcome to part four of my AWS Security overview. In part three, we looked at network security at the subnet level. This ti...
Top 13 Amazon Virtual Private Cloud (VPC) Best Practices
Amazon Virtual Private Cloud (VPC) brings a host of advantages to the table, including static private IP addresses, Elastic Network Interfaces, secure bastion host setup, DHCP options, Advanced Network Access Control, predictable internal IP ranges, VPN connectivity, movement of interna...
Big Changes to the AWS Certification Exams
With AWS re:Invent 2019 just around the corner, we can expect some early announcements to trickle through with upcoming features and services. However, AWS has just announced some big changes to their certification exams. So what’s changing and what’s new? There is a brand NEW ...
New on Cloud Academy: ITIL® 4, Microsoft 365 Tenant, Jenkins, TOGAF® 9.1, and more
At Cloud Academy, we're always striving to make improvements to our training platform. Based on your feedback, we released some new features to help make it easier for you to continue studying. These new features allow you to: Remove content from “Continue Studying” section Disc...
AWS Security Groups: Instance Level Security
Instance security requires that you fully understand AWS security groups, along with patching responsibility, key pairs, and various tenancy options. As a precursor to this post, you should have a thorough understanding of the AWS Shared Responsibility Model before moving onto discussi...
Cloud Migration Risks & Benefits
If you’re like most businesses, you already have at least one workload running in the cloud. However, that doesn’t mean that cloud migration is right for everyone. While cloud environments are generally scalable, reliable, and highly available, those won’t be the only considerations dri...
Real-Time Application Monitoring with Amazon Kinesis
Amazon Kinesis is a real-time data streaming service that makes it easy to collect, process, and analyze data so you can get quick insights and react as fast as possible to new information. With Amazon Kinesis you can ingest real-time data such as application logs, website clickstre...