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

  • Home
  • SEARCH
  • 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 6756127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:29:14+00:00 2026-05-26T13:29:14+00:00

I created a small chat application in Sinatra and jQuery on heroku. It simply

  • 0

I created a small chat application in Sinatra and jQuery on heroku. It simply inserts a message to a database when user submits it. And also downloads new messages every 2 seconds. After a few minutes of testing it stopped working and I received an email form heroku:

Hi,

We noticed that the gisekchat app had a large number of connections
open to the shared database. We had to limit the number of connections
to the shared database due to performance reasons. Can you either
reduce the number of overall connections to the shared db or move to a
dedicated database?

It does appear that you’re not taking advantage of connection pooling
and are opening a new connection to the database for each request from
your app.

Thanks,
-Chris

This is the action supporting submitting a message (receiving is very similar):

post '/send' do
  con = con = PGconn.connect($dbhost, 5432, "","",$dbname, $dbuser, $dbpass)
  con.exec("insert into messages(usr, msg, date) values('#{params[:usr]}','#{params[:msg]}', now())")    
end

How should I change it to enable connection pooling?

  • 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-26T13:29:15+00:00Added an answer on May 26, 2026 at 1:29 pm

    Yeah well it’s true, you really are opening a new connection to the database each time there is a ‘send’-post send.

    So you’ll need to change that. One Possibility may be, to open the connection globally:

     $con = PGconn.connect($dbhost, 5432, "","",$dbname, $dbuser, $dbpass)
    

    This should be done after you initialized your $dbname… variables, but before you use any routes.

    However, if you are using the modular sinatra version, instead of the classic one, you could declare an instance variable with

    attr_accessor :con
    

    and initialize it before the app is started.

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

Sidebar

Related Questions

I've created small database under SQL Server 2008 . Now i wanted to move
I created a small WPF desktop application. I am thinking about how to make
I have created a small application which opens,reads and creates Excel files. The app
I have created a small application using Microsoft .NET. I don't have problems with
I have created a small chatting application in C#, and started as a Console
I've created a small user control consisting of a button whose content is an
I am learning about threading and multithreading..so i just created a small application in
i created a small rails application for learning which has 3 models : class
I have created small test web application which makes use of LINQ to SQL.
I created a small function that simply writes text to a file, but I

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.