Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:22:48+00:00 2026-05-27T13:22:48+00:00

I know this is a very generic and subjective question, so feel free to

  • 0

I know this is a very generic and subjective question, so feel free to vote to close it if it does not meet the StackOverflow netiquette.. but for me, it’s worth trying 😉

I’ve never built a high-traffic application since now, so I’m not aware (except for some reading on the web) about scaling practices.

How can I design a database that, when a scaling is needed, I dont have to refactor the database structure, or the application code?

I know that development (and optimization) should come step-by-step, optimize bottleneck as they happen, and is nearly impossible to design the perfect structure when you don’t know how many users you’ll have and how would they use the database (e.g. read/write ratio), I’m just looking for a good base to start.

What are the best practices for making a structure almost ready to be scaled with partitioning and sharding, and what hacks must be absolutely avoided?

Edit some detail about my application:

  1. The application will run as a multisite behavior
  2. I’ll have a database for each application version (db_0_0_1, db_0_0_2, etc..)*
  3. Every ‘site’ will have a schema inside a database* and a role that can access only his own schemas
  4. Application code will be mostly PHP and few things (daemons and maintenance things) in Python
  5. Web server will probably be Nginx and lighttpd or node.js as support for long-polling tasks (e.g. chat)
  6. Caching will be done with memcached (plus apc for things strictly related to the php code, as it can be used outside php)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:22:49+00:00Added an answer on May 27, 2026 at 1:22 pm

    The question is really generic, but here are few tips:

    • Do not use any session variables (pg_backend_pid(), inet_client_addr()) or per-session control (SET ROLE, SET SESSION) in application code.

    • Do not use explicit transaction control (BEGIN/COMMIT/SET TRANSACTION) in application code. All such logic should be wrapped in UDFs. This enables stateless, statement-mode pooling which enables fastest possible DB pooling. (see pgbouncer docs, and pg wiki for more info)

    • Encapsulate all App<->Db communication in well defined DB API of UDFs – this will let you use PL/Proxy. If doing this with all SELECTs is too hard, do it at least for all data writes (INSERT/UPDATE/DELETE). Example: instead of INSERT INTO users(name) VALUES('Joe') you need SELECT create_user('Joe').

    • check your DB schema – is it easy to separate all data belonging to given user? (most probably this will be the partitioning key). All that’s left is common, shared data which will need to be replicated to all nodes.

    • think of caching before you need it. what will be caching key? what will be cache timeout? will you use memcached?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, I know this is a very lame question to ask and not of
I know the title of this question is not very descriptive, but I didn't
I know this is a very broadly scoped question, but what do I need
guys I know this question is very basic but I've met in few publications
Ok, I know this is a very basic question, but my head is swimming
What is smart phone development? I know this is a very broad question, so
This is probably a very generic question but I will shoot anyway since I
I'm afraid this is a very generic question, but unfortunately my question is exactly
This is a generic question, I don't know if it belongs to Programming or
Most of you will probably label this is a very generic question, but still,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.