
How I Built My First End-to-End MLOps Pipeline on AWS
As a beginner exploring MLOps, I wanted to understand what happens beyond training a machine learning model. In this article, I share my experience building an end-to-end pipeline on AWS using Amazon SageMaker, AWS Lambda, and Amazon S3 for Titanic survival prediction. Along the way, I ran into networking issues, debugging challenges, and deployment hiccups that taught me valuable lessons about building production-style ML workflows
Building My First End-to-End MLOps Pipeline on AWS
If you're new to MLOps, you've probably come across plenty of tutorials that explain what each AWS service does. What I struggled to find was a guide that showed what it actually feels like to build an end-to-end pipeline for the first time, including the mistakes and debugging along the way.
Yesterday, I decided to change that by building my own project.
I used the classic Titanic Survival dataset with scikit-learn. The dataset itself wasn't the challenge. I chose it because I wanted to focus on learning the MLOps workflow instead of spending time improving model accuracy. My goal was to understand how to train a model, deploy it with SageMaker, benchmark it, and troubleshoot the issues that came up in between.
Getting Everything Ready
Before writing any machine learning code, I set up the AWS resources I knew I'd need.
I created an IAM user for programmatic access, configured the AWS CLI on my laptop, created an S3 bucket, and organized it into folders for raw data, model artifacts, SageMaker artifacts, and experiment data. Once everything was in place, I uploaded the Titanic dataset and was ready to start building.
It wasn't the most exciting part of the project, but having a clean structure from the beginning saved me from unnecessary confusion later.
My First Roadblock
My original plan was to do everything inside SageMaker Studio. Since it's AWS's managed development environment, it seemed like the obvious place to start.
Unfortunately, things didn't go as planned.
The Studio domain I created ran into networking issues because of its VPC configuration. I spent a few hours trying to fix it by setting up VPC endpoints and checking my configuration, but nothing worked. The more I debugged, the more I realized I was learning about networking instead of MLOps.
So I changed my approach.
Instead of using SageMaker Studio, I ran Jupyter Notebook locally and connected it to AWS using the AWS CLI credentials I'd already configured. That simple change solved the networking problem immediately. I could still upload files to S3, train models, and deploy SageMaker endpoints without relying on Studio.
Looking back, this was one of the biggest takeaways from the project. SageMaker Studio is convenient, but it isn't required. If you're learning and Studio becomes a blocker, running locally is a perfectly valid alternative. You still get access to the same AWS services while avoiding a lot of unnecessary complexity.
Training and Deploying the Model
With the networking issues out of the way, I could finally focus on the machine learning part of the project.
I trained a Random Forest Classifier using scikit-learn on the Titanic dataset and achieved 82.68% accuracy on the test set. That was good enough for this project because my focus wasn't squeezing out another 2–3% accuracy. I wanted to understand how a model moves from training to deployment in a real MLOps workflow.
Once the model was ready, I saved it as
titanic_model.pkl . The next step was to make it available for inference using Amazon SageMaker.To do that, I created a SageMaker execution role, packaged the model artifacts into a
model.tar.gz file, uploaded it to S3, and deployed my first SageMaker endpoint.The deployment completed successfully, so I assumed I was done.
I wasn't.The Endpoint Couldn't Read My Input
When I sent my first prediction request, the endpoint failed almost immediately.
After some debugging, I realized the issue wasn't with the model at all. SageMaker's default inference container expected the input in a specific format, but I was sending a JSON dictionary.
To fix that, I created a custom
inference.py script with four functions that SageMaker looks for during inference:-
model_fnto load the trained model
-
input_fnto process incoming requests
-
predict_fnto generate predictions
-
output_fnto format the response
Once I added the custom inference script and redeployed the model, the endpoint started accepting JSON requests correctly.
That was another useful lesson. The default inference container works well for simple use cases, but the moment your input format changes, you need to tell SageMaker exactly how to handle it.
Updating the Endpoint
After fixing the inference script, I had two options. I could delete the existing endpoint and create a new one, or update the one that was already running.
I chose the second option.
Instead of starting over, I created a new model version, attached it to a new endpoint configuration, and updated the existing endpoint. SageMaker handled the deployment automatically, so I didn't have to worry about downtime or changing the endpoint name.
From the outside, nothing changed. Internally, the endpoint was now serving predictions using the updated model and inference script.
By this point, I finally had a working endpoint that could accept JSON input and return predictions successfully. The next question was whether it performed well consistently, and that's where benchmarking came in.
Benchmarking the Endpoint
Getting a successful prediction from the endpoint felt great, but I also wanted to know how it performed over multiple requests.
To test that, I built a simple benchmarking setup using AWS Lambda.
I uploaded a small sample dataset to S3 and created a Lambda function that would read one row at a time, send it to the SageMaker endpoint, and record the prediction along with the response time. I then used a PowerShell script to invoke the Lambda function for every row in the sample dataset.
My first test didn't go very far.
The function failed with a
ValueError because the sample dataset still contained values like "male" and "S" for categorical features, while the model expected their encoded numeric values. It was the same preprocessing mistake I had already encountered during deployment.Once I added the required mappings inside the Lambda function, everything worked as expected.
That experience reinforced something I hadn't fully appreciated before: every stage of an ML pipeline has to agree on the format of the data. Your training data, inference endpoint, and benchmarking code all need to speak the same language.
The Results
After fixing the preprocessing issue, I ran the benchmark again.
All 25 requests completed successfully.
The first invocation took about 216 ms, while the remaining requests finished in roughly 14 to 48 ms, with an average latency of around 26 ms.
The difference surprised me at first, but it turned out to be a classic Lambda cold start.
Since the first request had to initialize a new execution environment, it naturally took longer. Once the environment was warm, the following requests were much faster. I'd read about cold starts before, but seeing the difference in my own benchmark made the concept much easier to understand.
Looking Back
When I started this project, I thought building an MLOps pipeline was mostly about training and deploying a model.
I quickly realized that the model was only one piece of the puzzle.
I spent just as much time troubleshooting networking issues, handling input formats, packaging model artifacts, updating endpoints, and making sure every part of the pipeline expected the same data. Those were the parts that taught me the most.
If I had to give one piece of advice to someone starting their first MLOps project, it would be this: don't be discouraged when things don't work the first time. Most of my learning came from debugging problems I hadn't expected, and each one helped me understand AWS a little better.
This project may be small, but it gave me a much clearer picture of how an end-to-end MLOps workflow fits together. My next goal is to build on it by adding monitoring, automating deployment with CI/CD, and experimenting with retraining pipelines.
For now, though, I'm just happy that what started as a simple Titanic prediction model turned into a hands-on introduction to MLOps on AWS.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article