Friday, May 1, 2026
HomeBig DataConstructing a Serverless Microservice Utilizing Rockset and AWS Lambda

Constructing a Serverless Microservice Utilizing Rockset and AWS Lambda

[ad_1]

Rockset makes it simple to develop serverless microservices, knowledge APIs, and data-driven purposes. This video demo reveals an instance of what is attainable with Rockset. For this train, we are going to construct a serverless microservice to find the inventory symbols with essentially the most mentions on Twitter.


e59e6e97b5644ea87b8522a8d0295470

Ingest

Our Twitter stream comes from Amazon Kinesis and is constantly ingested into Rockset. It is a easy course of to arrange a dwell integration between Rockset and Kinesis from the Rockset console. Consult with our step-by-step information for extra particulars, together with information on organising the Twitter Kinesis stream.

We additionally wish to mix the inventory mentions from Twitter with details about these shares from Nasdaq. This info comes from a file in Amazon S3 and is ingested right into a second Rockset assortment.


lambda microservice

Question

Rockset robotically infers the schema for the Twitter JSON knowledge within the twitter-firehose assortment. We’ve not carried out any transformation on the info, however we are able to instantly run SQL queries on it. Analyzing the outcomes of our SQL question, word how the Twitter knowledge is organized in a number of ranges of nesting and arrays.


nested json

In our instance, we’re particularly targeted on tweets that comprise inventory mentions, which we discover below the symbols arrays within the entities discipline. We steadily discover the info and construct out our SQL question, becoming a member of tweet knowledge with the Nasdaq firm information within the tickers assortment, to return the preferred shares in our knowledge set together with some descriptive information about every inventory.

-- unnest tweets with inventory ticker symbols from the previous 1 day
WITH stock_tweets AS
      (SELECT t.consumer.identify, t.textual content, higher(sym.textual content) AS ticker
       FROM   "twitter-firehose" AS t, unnest(t.entities.symbols) AS sym
       WHERE  t.entities.symbols[1] will not be null
         AND  t._event_time > current_timestamp() - INTERVAL 1 day),

-- combination inventory ticker image tweet occurrences 
    top_stock_tweets AS
      (SELECT ticker, depend(*) AS tweet_count
       FROM   stock_tweets
       GROUP BY ticker),

-- be a part of inventory ticker image in tweets with NASDAQ firm listing knowledge
    stock_info_with_tweets AS 
      (SELECT top_stock_tweets.ticker, top_stock_tweets.tweet_count,
              tickers.Identify, tickers.Business, tickers.MarketCap
       FROM top_stock_tweets JOIN tickers
         ON top_stock_tweets.ticker = tickers.Image)

-- present prime 10 most tweeted inventory ticker symbols together with firm information
SELECT * 
FROM   stock_info_with_tweets t
ORDER BY t.tweet_count DESC
LIMIT 10

Construct

Rockset lets you export your SQL question and embed it as is into your code.


export python

For our demo, we have constructed a Python-based serverless API, utilizing AWS Lambda, that returns the inventory symbols occurring most frequently in tweets. (Different language shoppers, together with Node.js, Go, and Java, are additionally accessible.)


As soon as arrange, we are able to serve dwell queries on uncooked, real-time Twitter knowledge. In these outcomes, the corporate Identify, Business, and MarketCap come from the Nasdaq firm information.


lambda api

We are able to additionally construct a rudimentary app that calls the API and shows the inventory symbols with essentially the most mentions on Twitter for customizable time intervals.


lambda api app

We have offered the code for the Construct steps—the Python Lambda operate and the dashboard—in our recipes repository, so you may lengthen or modify this instance in your wants.

There’s rather a lot occurring on this instance. We have taken uncooked JSON and CSV from streaming and static sources, written SQL queries becoming a member of the 2 knowledge units, used our remaining SQL question to create a serverless API, and referred to as the API via our app. You’ll be able to view extra element on how we carried out this serverless microservice within the video embedded above. Hopefully this demo will spur your creativeness as you think about what you may construct on Rockset.



[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments