3 ms·
This is not what is usually meant by a third tier. Personally I take database connection pooling for granted. What I mean when I talk about a 'data-tier' is th
by st3fan 18y ago
This is not what is usually meant by a third tier. Personally I take database connection pooling for granted.
What I mean when I talk about a 'data-tier' is the code that deals with accessing data without knowing in whatever datastore it is contained.
If you properly hide for example Twitter#getRecentMessagesForUserById(userId) behind a (Java) interface then you can easily change from an implementation where you do direct database calls to a sharded solution or a cached solution.
Other tiers that use this API will simply work because the interface has not changed. One day your app could be talking directly to a single MySQL database and the other day your app could be talking to a 60 node PostgreSQL cluster. It would never know since the details are hidden.
This is totally against what you see in every Rails book or example app where the first thing that is done is direct ActiveRecord queries.
Yes it is more work, but it pays off in the long term. It also greatly reduces local hacks for caching. All that is done in the right place. And automatically for all users of that tier.
S.
- melvinram 18y agoMaybe I'm misunderstanding what your saying but I'd like to point out that I can go from MySQL to PostgreSQL in a matter of minutes. Specifically, I would need to change my database.yml file with my new database info and run a migration. Did I miss something?
- gaius 18y agoA slight tangent, but I never understood the philosophy of being database-agnostic. Every database has its own set of features and does things in a certain way. For example, in some databases cursor operations are expensive and temporary tables are the way to go. In some, the opposite. Remaining neutral means using only the most basic SQL and still you might not get the expected performance...