Transforming Logs into Real-Time Insights: Creating a Multi-Client Streaming Service With Python

Yuvraj (~yuvraj4)


6

Votes

Description:

Join me for an exciting talk on building a real-time multi-client log streaming service using Python and Server-Sent Events

Description In this talk, we will explore how to build a real-time log reading service using Python and Server-Sent Events. We'll dive into the high-level architecture of a log aggregator service, covering the server, clients, and log generator. Obviously, we can't have logging without AI (said no one ever), and so additionally, to mirror the current trend, we'll be getting our hands dirty with a practical application of Generative AI: leveraging large language models (LLMs) to utilise natural language search queries for filtering out log data to enable powerful and easy debugging for different use cases.

Gain low-level implementation insights into how tools like Grafana Loki work under the hood.

We'll deal with problem statements such as -

  1. How to ensure that the latest added logs are sent to the client
  2. Tailing consecutive logs
  3. Handling potential technical issues that may arise.
  4. Productionising our LLM integration

But that’s not all! We’ll also cover how to stream live data to multiple clients simultaneously. You’ll discover how Server-Sent Events can be used as an alternative for long polling since it maintains a single connection and keeps a continuous event stream going through it.

We’ll use Python FastAPI to write an async web server and libraries that work well with FastAPI to wrap around Python generator objects and transform them into SSE signals that can be streamed to clients. We’ll make use of the curl command line tool to query the API and establish a connection with the server. Lastly, we’ll also containerise the entire application with Docker and learn how to execute scripts inside running containers.

Key Takeaways

  • Learn how to build a real-time log reading service using Python
  • Discover how Server-Sent Events can be used as an alternative for long polling
  • Gain insights into potential technical issues that may arise
  • Get your hands dirty with Gen AI by applying it to a real-life application
  • Learn how to stream live data in real-time
  • Evaluate possible solutions and document the pros and cons of each
  • Improve your Python skills

TL;DR:

Join this talk to learn how to build a real-time multi-client log streaming service using Python and Server-Sent Events. We'll cover the architecture of a log aggregator service, practical applications of Generative AI for natural language search queries, and insights into tools like Grafana Loki. You'll also learn how to stream live data, handle technical challenges, and use FastAPI with SSE to maintain continuous event streams.

As a by-product of attending the talk, the attendees will also understand how to set up an async web server with FastAPI and Uvicorn and learn how to containerize the service using Docker. Furthermore, they will gain insights into evaluating potential solutions and documenting the pros and cons of each technology that can be implemented to solve a problem. Lastly, participants will get to apply Generative AI to a real-life use case, experiencing its application in real time.

Prerequisites:

To follow along with this talk, attendees should have a basic understanding of Python and web development. They should also have access to a computer with Python 3 installed, Docker installed, and an active internet connection to access a GitHub repository.

Content URLs:

I previously presented "a version" of this talk at PyDelhiConf 2023. Below, you'll find a link to the slide deck I used, along with a video recording of the live stream of my presentation as well as the GitHub repository associated with the demo:-

Talk Link

Speaker Info:

I'm a product-first software engineer who's all about building efficient and scalable backend services to supercharge applications. I've been programming since the age of 17, and my passion for it has grown ever since. There's nothing quite like the satisfaction I feel when I see my code being used in a live application that solves real-world problems for actual people. Knowing that I've played a part in making someone's life a little easier or better drives me to keep learning, growing, and pushing myself to do even better work. At the end of the day, there's no greater reward than seeing the impact of my work and knowing that it's making a positive difference in the world.

Currently, I'm working as an SDE at CloudSEK, where I operate at the intersection of Gen AI, data, and backend engineering to enhance cyber protection coverage for our clients. Additionally, when I'm not working, you can find me producing music or at the gym.

Speaker Links:

This links to my portfolio which includes a consolidated overview of my professional journey

Section: Python in Platform Engineering and Developer Operations
Type: Talk
Target Audience: Intermediate
Last Updated: