Mayank Pathak
4.8K posts

Mayank Pathak
@circuiteye
Engineering Stuff....
India Katılım Ekim 2014
1.1K Takip Edilen707 Takipçiler
Mayank Pathak retweetledi

#BREAKING: India’s IT Minister Ashwini Vaishnaw at Davos strongly counters IMF Chief for calling India a second-tier AI power:
“I don't know what the IMF criteria is but Stanford places India at 3rd in the world for AI preparedness. I don't think your classification is correct.”
English
Mayank Pathak retweetledi
Mayank Pathak retweetledi

Is @LeetCode down, guys? Anyone else facing this issue?
@Cloudflare seems to be working fine. What else could be the issue?
#LeetCode #down


Madera, CA 🇺🇸 English
Mayank Pathak retweetledi
Mayank Pathak retweetledi
Mayank Pathak retweetledi

We need to create an ecosystem in India where successful entrepreneurs, after building and scaling their businesses, are ready to invest their time, money, and energy into deep tech research.
I’m glad to see people like @deepigoyal investing in deep R&D, and @bhash working on a gigafactory. India may not yet have many such examples, but the some who have shown what’s possible.
The YC system works because of strong networks -> people who can connect you, introduce you, and give you access to opportunities. In this space, network is money.
We also have some amazing creators in tech who are making a huge impact, making education accessible, simplifying complex topics, and pushing the ecosystem forward. For example: @arpit_bhayani explaining deep concepts, @kubesimplify covering Kubernetes and cloud-native, and @kunalstwt teaching DSA. But we need more such creators who can bridge the knowledge gap.
In the end, we need an ecosystem with a ready pool of capital dedicated to deep tech and research. I really like the a16z @speedrun concept - if top billionaires created such a pool, with domain experts empowered to write checks to the next generation of entrepreneurs willing to take risks, India’s potential could truly be unlocked. We have the brains, we just need the right advice, mentorship, and support to channel them.
This isn’t only about money. It’s also about having the right mentors and experienced people who can guide.
There are many more I’d like to tag here, but I don’t want to do it just for the sake of tagging. The point is simple: India currently lacks a YC-like ecosystem where successful founders who’ve exited are actively betting on the future.
Finally, we need full government support to make the investment process as smooth as possible. Indian founders and investors should feel safe and empowered, not lost in complexity. @narendramodi it’s time to make India rise, not slowly, but faster than anyone ever thought possible.
Let’s get this done! 🚀
English
Mayank Pathak retweetledi

A 🧵on Database Connection Pooling and how to build an application using AWS Lambda (serverless)?
I wanted to talk about lambda but some people may not know about connection pools so giving some context.
When you build an application, you set up an application server then a DB. Application server query DB to get the data.
Transferring data can't happen without a connection. Like when a client calls an app server it setup transfers data on a TCP connection. In the same way when app server queries from DB, it has to setup a connection.
The following happens in setting up connection:
1) Find DB
2) Connection to it
3) Authenticate connection
After that connection is set, then the query (SELECT * FROM table) executs.
Did you see a problem?
Querying from DB takes time in 2 things:
1) Making the connection
2) Executing the query
It has two disadvantages:
1) High latency because you are doing two things.
2) If suddenly 1 lakh concurrent users come to the app and the connection limit of DB is 100 and you are creating separate connections for each 1 lakh users then DB failure may happen.
Solution:
- We make a certain number of connections (called connection pool) and reuse them every time.
- Suppose DB has a limit of 100 connections then we make 100 connections and store them as a state in the application server. When a new user comes, it takes that connection, perform query then release that connection.
- Now, you may be wondering, if more than 100 concurrent users came then they have to wait since all connections are already in use. Yes, but this is fine. Query happens very fast so the next connection will be available very soon.
There are several libraries that helps you to maintain connection pool like in Java, you can use Hikari.
Many ORMs have in-built connection pool features like if you use NodeJS with "Prisma" then it by default maintains 10 connection pools. If you want to change its number, you just need to add one line of syntax (check documentation).
Now, comes to our second question. How to build an application in AWS Lambda?
If you heard about serverless then you may know that they are stateless. This means if no users come to your site, the application is OFF. So, all the connection is destroyed.
It also has autoscaling so if 1 lakh lambda functions are being used to serve the users and if you wrote this connection pool logic inside lambda then again you will face the same issue that no. of connection exceeded.
Solution?
What is the common solution for maintaining consistency of state in a scalable architecture? May be you guessed it.
We will make an EC2 server as a proxy which will maintain this connection pool state. Lambda function will contact this EC2 server to get the connection and perform the query or maybe this EC2 server will perform the query and give the result to lambda.
But again we got an overhead of maintaing an EC2 server and its scaling.
AWS released a very nice solution to this few years back. We can use use AWS RDS Proxy. It is a managed service that maintains this connection pool.
And we all like managed services (like load balancer etc) because their scaling, failure, security etc are maintained by AWS and we don't have to worry about and focus on building application.
It also solves our problem of maintaining connection in distributed autoscaling servers. Since it acts as a global server to maintain the state and maintain consistency in no. of connections.
Last thing, I couldn't release any blog last month because I was being lazy. But this month I will continue my AWS series and will put some blogs on Java and Springboot also.
English
Mayank Pathak retweetledi

A girl messaged me today. At first, I was confused about where she had gotten my number, then I remembered… oh, I had put it out there in my resume post.
But bro, you won’t believe what she sent me in the message. Honestly, I was not ready for this. She drops two photos: one of her ex-boyfriend, and the other one of me. Then she comes at me with: "See? You and my ex are the same person! You took money from me back then, and I want it back!"
I’m like, what? Only my nose looks like the guy in her photo! I keep telling her, "We’re not the same person," but she is not ready to accept it.
Now, at this point, the only hope I have is my last line of defense – a Cosine Similarity Test.
I know you guys are thinking, what the hell is this Cosine Similarity.
Cosine similarity is nothing but a mathematical way to measure how similar two things are by treating them as vectors in space. Think of it like measuring the angle between two arrows - the smaller the angle, the more similar they are.
See, in math, cosine similarity works like this:
cos(θ) = A·B / (|A| × |B|)
Where:
- A·B is the dot product of A and B.
- |A| and |B| are the magnitudes.
Understanding the Scale (-1 to 1):
- cos(0°) = 1 → Perfectly identical
- cos(45°) = 0.7 → Partially similar
- cos(90°) = 0 → No similarity at all
- cos(180°) = -1 → Complete opposites
Let’s take an example of two vectors and calculate the cosine similarity score:
Vector A = [1, 3, 4, 2]
Vector B = [2, 6, 8, 4]
Step 1: Calculate Dot Product:
The dot product is the sum of the products of the corresponding elements of two vectors
A·B = [1, 3, 4, 2] · [2, 6, 8, 4]
A·B = 1×2 + 3×6 + 4×8 + 2×4
A·B = 2 + 18 + 32 + 8
A·B = 60
Step 2: Calculate Magnitude of Vectors A and B and multiply:
The magnitude is nothing but the square root of the sum of the squares of the vector elements:
A = [1, 3, 4, 2]
|A| = √(1² + 3² + 4² + 2²)
|A| = √(1+9+16+4)
|A| = √30
B = [2, 6, 8, 4]
|B| = √(2²+6²+8²+4²)
|B| = √(4+36+64+16)
|B| = 2√30
|A| × |B| = √30 × 2√30
|A| × |B| = 2 × 30 = 60
Step 3: Put values in the formula:
cos(θ) = (A·B) / (|A| × |B|)
cos(θ) = 60 / 60
cos(θ) = 1
Cosine = 1 means Vector A and B are perfectly identical.
Congratulations 🎉, you just learned how to find the cosine similarity score.
Bonus:
Why does AI/ML care about cosine similarity?
Recommendation Systems – Netflix uses it to find movies similar to what you’ve watched, comparing user preference vectors to suggest content you’ll likely enjoy.
Natural Language Processing – Search engines use cosine similarity to match your query with relevant documents by comparing word embedding vectors.
Image Recognition – AI systems compare feature vectors extracted from images to identify objects, faces, or detect similarities between pictures.
Document Classification – Text classification systems use it to categorize emails as spam/not spam by comparing document vectors with known patterns.
Clustering Algorithms – Machine learning models group similar data points together by measuring cosine similarity between feature vectors, helping identify patterns in large datasets.
English

@takeUforward_ 1.5 yr tk andha kaam kiya below avg pay pe with no increment, abhi increment cycle mai grade acha de diya aur paise na ke barabar bdaye😭. Gareebi continuess....
English


After 5 years... finally going back to my village.
Will be posting a little less for the next 10 days, gonna spend time with my family, breathe in fresh air, and live those simple moments I've missed so much.
I think I should take a little break for a while, just me and nature.
Will come back stronger with some solid stuff, literally. 🫶🫶
Super excited and super happy.
Byyee byee for now... will keep dropping some greenery and village vibes here.
See you all soon!

English
Mayank Pathak retweetledi

Respected Sir @Gen_VKSingh ,
We need your help in saving my friend's father's life(Mr. Sanjay Pathak). His Father is in an end stage liver cirrhosis disease and needs an immediate liver transplant, their financial condition is not stable right now.
Please take a look & help us


English







