Comments (2)
Exploration
Architecture
The https://github.com/rehanvdm/serverless-website-analytics/tree/experiment-timestream branch contains the experiment/poc with Amazon Timestream. The PR showing the changes can be seen here.
The ingest API stays the same and is writing to a Kinesis Firehose that has a buffer window of 1 minute, it then stores the data as JSONL (JSON Lines) on an S3 bucket. The S3 bucket sends create notifications to an SQS queue, the SQS then triggers a Lambda function that writes it into Timestream in batches of 100.
Performance
Timestream does not like to return big result sets. Athena is 3 to 4 times faster in small result sets and up to 40 times faster with big result sets.
https://twitter.com/der_rehan/status/1723782017462993121
FAQ
Why use Firehose before the SQS?
With SQS you can only specify the maximum wait period, it can trigger your function anytime before that. With Firehose it will wait exactly that time, or until the buffer is full. We want to wait exactly that time, in this case 1 minute, as we will have multiple page view events (first for opening the page, second for time on the page). The Lambda function can then dedupe them a little and only write 1 record instead of two, reducing the writes we do to Timestream.
from serverless-website-analytics.
Final verdict
Against Timestream
- Available in only certain regions: US-east-1, US-east-2, US-west-2, and EU-west-1
- Maximum record size 2 Kilobytes
- Have seen some people struggle with ingestion
- Can not join with other tables
- SLOW
- Not idempotent, inserting the same records with same version throws an error. But not the end of the world
- Has to scale, Firehose to S3 does not have to, sure there will be limits, but feels less scalable.
- More complex error handling compared to Athena
Benefits of Timestream
- No Schema
- Can be used for mealtime out of the box if desired. Could also with Athena but this would then be cheaper.
Decision
We will not be going with Timestream, the Athena based solution we have is faster. It works out to about the same amount per month, rough calculations. I have a hunch that it *might be cheaper to query if querying thousands and thousands of times, but also not sure. The Timestream solution is nice because then I don't have to define the schema in IaC (on the Firehose and Athena table) but it also introduces more error handling, with the SQS and Lambda writing into Timestream.
In the end, the benefits do not outweigh the cons. We will be sticking with Athena, for now.
from serverless-website-analytics.
Related Issues (20)
- Clicking on a referrer should have a context menu instead HOT 1
- Outbound link tracking HOT 1
- Add performance tracking
- Logo and favicon
- Email reports HOT 1
- Auto analyize traffic
- Add option to view by hour/day HOT 4
- Document query your own data HOT 1
- Uptime monitoring
- Add time filtering
- Auto vacuum if X amount of records have been ingested for that day
- Insights
- Experiment Glue Table Statistics HOT 1
- S3 Express One Zone
- Anomaly Detection HOT 1
- Udpate Anomaly Detection Algorithm so that it better detects when an anomaly is over HOT 6
- Basic real time view
- Use LLRT runtime if possible
- Bug: wrong A record for Cognito domain if using a subdomain HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-website-analytics.