A Depressive Journey With MongoDB
mengu.net
mengu.net
The bottom line is there were only 4 days to go from idea to supporting 30k concurrent users. That is a recipe for disaster. There are so many things to consider and implement in addition to the software. Nevermind the fact that there were probably laughable requirements for this project and no time allocated to design and testing. There wasn't even sufficient hardware to support the application. This project was a failure almost from the moment it was conceived. This guy never even had a chance.
There is a story in here, but it is not so much about MongoDB.
http://www.mongodb.org/display/DOCS/Connections
That page says each connection spawns a thread. That could be a good lead. The documentation suggests using a connection pool (although many drivers will do this automatically). Were you using one?
http://stackoverflow.com/questions/8439639/mongodb-max-conne...
That StackOverflow question is about supporting 20k concurrent users.
It could also be a matter of insufficient hardware. I don't know, but I would start looking at what kind of performance can be expected in different setups and go from there. The most important thing is to properly test your setup. Prepare for a process of trial and error and expect it to take some time.
1. Being expected to develop a fully working, robust application that accepts 30k users in 4 days
2. Agreeing to this commitment
I think are the big failures. Who in their right mind would agree to something like this, even going as far as taking responsibility for it?!
True, when it comes to it, your boss is your boss, fine - if your hand is being forced, do it under protest, rather than pretending this isn't a terrible idea.
The solution is fairly simple. You can either use persistent connections at the driver level (the PHP driver provides this, I'm not sure which other languages do), or you can put mongos (used for sharding) in front of mongod. Mongos does connection pooling and tremendously reduces the load on your mongod server.
The author of the post mentions that redis is "heaven sent". Well, redis handles its connections in an asynchronous fashion which is why it can handle a large amount of direct traffic gracefully. I believe there are plans to change mongo's connection handling to use select/epoll, but I'm not sure when.
While I respect your honesty, but after reading this particular blog post and a few bits of your website, I think you should slow down and value tried and tested tools.
Let's start with your "About me:"
"Mengu, is a web developer with Ruby on Rails, Grails, Django, Pyramid, web2py, CodeIgniter and jQuery in his tool box. Available for any kind of web development jobs. Read more.."
Lots of technology there. Then you take on a project where you chose MongoDB. I think I'm starting to notice a trend here.
You burned your team member for not standing up for your choice.
"Our manager accused me and MongoDB for the failure while we all have agreed to use MongoDB in the team. None of my teammates stood up."
My prejudice sense something is off: I felt that you were the one who pushed MongoDB hard to the point where your team member gave up and just "alright, let's just get this ball rolling since we have 4 days anyway..." rather than argue with you.
It fails. You got blamed alone. None of your team member stood up for your "ignorance" of tried-and-tested tools. That's fitting if I may say so.
Don't do that in public blog. Don't ever ever do that. Especially when it's your fault.
You also started off with saying that "MongoDB is okay" then trash the community and not willing to purchase for the support while admitting that you do need the support.
I know it has been hard for you but you really need to step back a little bit and do a retrospective on your decision-making ability.
I know I'm saying harsh thinsg but I hope you understand that there's a bigger problem and MongoDB is not that problem (at least not now).
In my short time in this hi-tech world, I've met and worked with a few people who religiously pushing new hip tools with zero experience (using the said tools) lately (especially lately, due to the explosion of blogs and hip tools) and would want to spread the blame to everybody else if it fails just because they agreed to use it. It's a common trend that most managers can see quickly and it may not be good for your future career.
He will grow from it and will do better next time.
Well there's your problem right there. That is not an appropriate timeframe for a new app. The only professional response to such a request is: "It cannot be done. Not if you want this app to work in production. Here's why." Follow up with an explanation of why QA and load testing are crucial. If they press you, make your next follow-up a letter of resignation.
DISCLAIMER You are about to read a long story on how I got burnt with MongoDB and depressed with it. I am not blaming MongoDB, anyone using, advocating or developing it. I am blaming myself for this. MongoDB is a good tool. You can use it but just make sure it is what you need and it handles your requirements very well. This is not specific to MongoDB but applies to every tool we use.
I think it's a bit harsh for people to criticise either him or MongoDB too much.
At the end of the day, it was a big rush job, no time was allowed for testing for scaling, and it fell over.
My only real surprise is that it wasn't Apache that fell over first.
The Apache web server is a very well-tested, tried and true piece of infrastructure, even if it's not "hip" these days.
Also - big question for me: were you using a ridiculously old version of mongo? I have yet to run into anyone who is on 2.0 or 1.8 and is still running master/slave (as opposed to replica sets). Sounds like your writes weren't working when you moved to replica sets because your client wasn't properly configured.
* Do not accept responsibility for anything that you had to do in a very limited time.
* Do not accept the job if the timeline is short, the work is big and the load is heavy.
* Load test your application no matter what the cost. If they want to get them all, they need to pay for them all.
Failing is hard, but I'm sure he learned :)
Wouldn't any database give you plain bad performance if settings were badly configured? I understand it was merely one of the reasons, but sometimes all you need is one.
my point in this is, if you have something that balance connections between servers, check if it kills them or not.
I think another takeaway from this is any time you need to adjust the ulimit, take a step back and ask "Does this make sense? Is my use case exceptional enough that it won't perform within the default limits set by my OS?"
Well, when you approach it like that...
Though, without meaning to criticize the author too much, increasing various ulimits should be standard on pretty much any database server, I would have thought?
and yes, increasing ulimits should be standard. one does simply forgets every single optimization when you just have to deliver a working app.
In saying that, I'm quite envious of your job, that sounds pretty cool (until things go wrong).
Hearing you pushing for a new tool at the last minute, then changing its setup/config/architecture repeatedly over a few days, then blaming your sysadmin for a setting. Man I'd hate to have that guys job, you just steamrolled him with "dev found a shiny new toy" behavior.
Thanks for posting this.
The OP missed:
When given a project that has high visibility and a very short timeline, don't wing it and choose a technology that 1. you have no experience with and 2. you've done no testing on.
Sorry, but I feel the OP is failing to see he made the critical error.
javascript:void(document.getElementsByClassName("post-body")[0].style.whiteSpace = 'pre-wrap')
"Do not accept responsibility for anything that you had to do in a very limited time." Yeah, because the ability to stand by your decision is a function of deadlines.
"Do not accept the job if the timeline is short, the work is big and the load is heavy." Wow, that's some pretty serious ambition right there.
I also like the way these points are first on the list, before actual lessons like: "Do not have trust in any of your tools until they prove themselves."
I hope he also learned from his error in judgement.
And he actually did have some courage in submitting his mistakes in public for us to discuss :)
It most certainly is.
One can be forced to come up with something under a tight deadline that he wouldn't under normal circumstances.