Joomla 产生很多mysql 数据库连接致使数据库报错

Joomla is causing “Too many connections” database errors

1 down vote favorite
 

I'm getting "too many connections" errors from mysql, and I think that its caused by recurring ajax calls that are hitting a joomla backend page.

I'm wondering, does Joomla make a new mysql connection for each page load, or would it store the connection in the PHP session?

How can I find this out?

shareimprove this question

1 Answer

active oldest votes
up vote 3 down vote accepted

The problem was that joomla was writing the session to a mysql db. Disabling that option resolved the "too many connections" error.

Just to clarify the steps I took in the Joomla admin:

Site > Global Configuration > System > Session Settings

Set Session Settings to None (or something other than database)

shareimprove this answer
  •  
    I have been having the same issue for some time now, however I have set the session setting to none since the begining of the month and I'm stilling seeing session info inserted into the jos_session table. Have you checked this table to see if you have info updated as people load your site? I would really appreciate your reply. Thanks! – user2051700 Feb 7 '13 at 17:04
  • 1
    @anaestrada What was happening for us was when we had more than about 80 people on our site, all the session writing to the mysql db would tie up all the mysql connections, and disabling it resolved that issue. After checking the database, it looks like Joomla is still using the session table though to keep track of users visiting the site, the difference is its not storing the $_SESSION array in there, which made a huge difference for us. – ContextSwitch Feb 7 '13 at 18:53

你知道国产商业软件背后的开源软件吗?

      现在各种国产软件已经牢牢占据了国内市场,无论是在浏览器、下载软件、压缩软件还是视频播放器等领域,都可以看到国产软件活跃的身影。诚然,国产软件在很多方面体验都不错,但之所以它们这么强,很大程度上是因为在核心技术方面,借用了相当多来自开源软件的技术。大家对国产软件都相当了解,但对于国产软件背后的开源软件,又知道多少?今天,就一起来谈谈国产软件背后的开源软件吧。

  养活了国产浏览器的Chromium

  国内有很多“极速浏览器”,所使用的是Chrome同样的引擎,这点大家都相当了解。不过,对于Chome背后的开源项目Chromium,大家了解的细节未必就这么多了。Chromium源于Webkit,而Webkit则源于DE开源项目,兴盛于苹果公司的Safari项目,所以说起来Chromium和苹果还是有一些渊源的。但是,Chromium又不仅仅是Webkit,Chrome只是继承了Webkit的WebCore部分,在JS引擎上使用了Google引以为豪的“V8”,还在Webkit上封装了一层Webkit Glue。可以说,Chromium对Webkit进行了相当程度的魔改。

Chromium是一堆国产极速浏览器赖以生存的基本


Chromium是一堆国产极速浏览器赖以生存的基本

  不仅如此,Chromium也已经转用了Blink内核,和Webkit的渊源就更加远了。国内浏览器使用了Chromium的源码,因此现在不少也换用了Blink内核。但是,国产浏览器继承的往往只是Chromium的内核和JS引擎,对其拓展支持部分,却大大被阉割。相较于Chrome,国产浏览器对各种扩展插件的支持都相当弱,往往只能安装修改后的扩展,这也许是出于商业上的原因。虽然国产软件对比Chrome默认多了很多功能,但扩展支持较弱这点,还是令可玩性大减。

  国产播放器的大奶妈:FFmpeg

  大家都喜欢用国产播放器看小电影,毕竟国产播放器的功能体验用起来真的不错,能够搜字幕,能够云播,最重要的还是支持格式比较全。但是,很多人并不知道,支持格式全这点,其实和国外的开源项目FFmpeg是息息相关的。

FFmpeg的解码器造就了无数万能播放器


FFmpeg的解码器造就了无数万能播放器

  FFmpeg是一个和视频处理相关的开源项目,包含了丰富的多媒体解码库。国内的播放器之所以如此万能,很大程度上就是因为使用了FFmpeg的解码库。但是,FFmpeg是基于LGPL/GPL开源的,这意味着如果某软件使用了FFmpeg的代码,那么这个软件涉及这些代码的部分,也必须开源。但是国内的风气嘛,你懂的,白拿了你的东西才不要守规矩。因此,国内的一些“XX影音”被钉在了FFmpeg的耻辱柱上。

  被占了便宜还被踢出门的7-Zip

  国内有很多免费的压缩软件,这些压缩软件的功能都挺不错,速度也可以,但内核往往也并非来自自己。国内压缩软件往往使用了7-Zip这款开源软件的内核,来实现众多压缩文件的支持。

  7-Zip这款开源软件的影响还是非常大的,首先它的效率很高。使用7-Zip编码的话,能够比WinZip和WinRAR提供更高的压缩率。另外它对各种压缩文件支持也非常好,主流的压缩文件基本都给予支持,当然一些商业的压缩格式例如rar,就只能解压不能压缩。由于7-Zip是开源的,所以它的内核被很多其他压缩软件所使用,国产压缩软件通常就是7-Zip的忠实拥簇。

7-Zip在国内不流行的一大原因可能就是界面太简陋


7-Zip在国内不流行的一大原因可能是界面太简陋,但就是这样的风格,社会你7哥,人狠话不多

  然而,7-Zip也是一款使用了LGPL协议的开源软件,使用了7-Zip的源码,按理来说也必须开源。但国内的“X压”等软件非但没有开源,还在压缩文件的文件头中故意加入无助于压缩的私货,让其他压缩软件无法解压。用了人家的代码还故意制造不兼容,对于这种行为,只想说一句,“我从未见过如此厚颜无耻之人”!

  为老司机铺开康庄大道的eMule

  如果你是有些年头的老司机,应该会知道VeryCD和电驴。VeryCD这个站点提供了大量eD2k链接,通过旗下的“电驴”软件,就可以下载到各种资源。虽然现在VeryCD已经转型,但各大下载软件依然对eD2k链接有着良好的支持,各种eD2k资源,也是老司机们飙车时绕不开的路。

  不过电驴和eD2k背后的eMule“电骡”,大家或许就知之甚少了。其实eD2k协议最早起源于商业公司开发的eDonkey(这才是正牌电驴)分享软件,有个德国人不满这软件,就自己开发了开源的客户端eMule电骡,也支持eD2k协议。国内的VeryCD把eMule电骡的开源代码魔改后,制造出了大家熟知的“VeryCD电驴”。

如果你没用过eMule,你可能不是真正的老司机


如果你没用过eMule,你可能不是真正的老司机

  和eMule电骡这个开源软件相比,其实VeryCD电驴阉割了相当多的东西。例如,不能直接在KAD网络上进行无限制的搜索,这意味着不能无限制地上各种车——现在流行的各种“种子搜索神器”,也只是阉割过的KAD搜索器罢了。现在VeryCD已经衰败,但eD2k仍长存于各大下载软件中,希望大家在开车的同时,也记得背后的eMule这位铺路人。

  智能路由器的力量之源:OpenWRT

  现在国内智能路由器可谓是如火如荼,智能路由器对比传统的路由器,功能的确强大很多。例如,可以外接硬盘当NAS用,还可以安装很多第三方插件,实现更强劲的功能。但是,智能路由器所依仗的OpenWRT,却鲜为人知。

没有OpenWRT,就没有一众智能路由器


没有OpenWRT,就没有一众智能路由器

  OpenWRT是一款开源的路由器固件,扩展性强是OpenWRT最大的卖点——这也是智能路由器们的最大卖点。OpenWRT源于Linux,其强大的拓展性很大程度上也是得益于Linux。不过和Linux一样,OpenWRT的使用门槛也比较高,原版需要命令行操纵,没有一定的Linux和网络知识还真是无法驾驭。国内的路由器厂商把OpenWRT改造成界面更友好的固件,可以算是OpenWRT的改版。

  不过,国内的智能路由器固件虽然上手容易,但对比OpenWRT,还是有一些方面例如性能和可玩性方面,是有所不如的。对比OpenWRT,智能路由器固件的性能和稳定性都要偏弱。特别是高流量时候的吞吐性能,差距会显得更加明显;而在扩展方面,由于技术和商业上的原因,可玩性也不如OpenWRT。而且,国内智能路由器厂商使用了OpenWRT,往往也不根据GPL协议继续开源,这些都是很值得批判一番的。

  总结

  在这个广告铺天盖地的商业社会,大家很少会听见开源软件的种种消息。闭源的商业软件搭造起了软件世界琳琅满目的繁华,但开源软件也未曾离开过栋梁的位置。诚然,国产软件的很多功能都相当容易上手,但在使用这些商业软件的时候,大家也应该记住背后默默奉献的开源项目,信息时代少了它们,也会失去很多光彩!

 

     评论:开源软件为中国快速提高软件水平,发展软件实力提供了机会。但是,从开源软件得到了好处,就不应该不按照开源的规则行事。不这样做,软件的水平和实力无法得到提高。开源软件是共产主义思想的果实。

10 Tips for a Fast Joomla Website

Is your Joomla website slow? You should definitely work on that: users hate slow websites, and they may leave your site earlier then they otherwise would, resulting in low conversion. Any site that needs more then 2 seconds to load could be at risk. Also, Google even says that site speed is used to determine your place in their rankings. What is nice to know: it should not be that hard to improve the speed of your Joomla website. While sometimes you can hear stories that Joomla is slow, this will usually be because of incorrect setup or bad hosting companies, and you can work on both. Especially if you know what to look at, improving the speed of your Joomla website may not be too hard, and making it load in less then a second should be possible.  
10 Tips for a Fast Joomla Website
 

Before jumping off, first make sure to check how fast your website currently is. There are a number of online tools that can help you to determine this. All of the following ones also give you detailed information about any possible issues:

Now that we know our current performance, let's start optimizing. One thing to keep in mind: Backup first! Then make step by step improvements, and after every optimization step, check that your site still functions correctly (make sure to clear your cache between steps).

1) Choose a good webhost

Choosing the right host for your website is crucial. Regardless of how well you may have optimized your website, a bad host can screw up all your efforts, and make your site slow. Before making your choice, check out reviews and forums. Especially avoid free hosts, sooner or later you will feel why they are free..... Also compare shared and dedicated hosting packages. Dedicated usually means faster, but of course it will be more expensive.

2) Joomla Cache

Cache is a way of serving pre-generated content to your users. This means that the server does not have to look up all information requested in the database every time a page is requested. Instead, a saved 'view' is offered to the browser (if your content has changed, this means the users temporarily receive old information, unless you clear your cache). Joomla is capable of serving 3 types of cache:

  • Component views
  • Module views
  • Page views

The first 2 settings are determined by one setting in your Global Configuration:

joomla-cache

Set it to Conservative. Optionally you can also set the time different than the default of 15 minutes. If globally, cache is switched on, you can switch it off again for specific modules from the Advanced tab in selected modules.

Page views are only cached if you switch on the System - Cache plugin in the Plugin Manager:

system-cache

Just set it to Enabled, and leave default parameters. Be aware that there can sometimes be issues with caching, especially for dynamic pages like contactforms, captcha's, etc.

If you have issues with cache, there are extensions that can assist you with this:

3) G-Zip

In Global Configuration, on the Server tab, you will find the setting to turn on G-zip:

g-zip

With G-zip turned on, your pages are compressed in a zip-file, sent to the browser on your PC, and unpacked there. Except for really ancient versions of IE, it is supported in all browsers, and should be safe to turn on.

After you have switched it on, you can use a tool to check the compression rate, like this one: www.feedthebot.com/tools/gzip. Often you will find that your content has been compressed over 50%!

If you find that it did not work, it could be that your host does not support mod_gzip, or has it switched off.

4) Remove unneeded extensions

Pick your extensions wisely. Some extensions have a horrible effect on your site speed. The major trouble makers are:

  • Social media scripts like counters for likes and tweets. They usually need additional javascripts, and connect to the remote network, which can slow you down terribly.
  • Large sliders and image shows. All images in the slideshow need to be loaded for the slider to function, which may take long with full-width images.
  • Also scripts like Googla Analytics, Google Webfonts, etc. can slow you down more then you would expect...

Even if you need features like these, at least think about whether you actually need them on your home-page. If you can off-load them to a contact-page or portfolio-page, only that page is affected!

5) Browser caching in .htaccess

Assuming you have renamed your htaccess.txt file to .htaccess, you can use it to add some code which tells your browser not to request specific image types from the server if they are already present on your PC. As often images make up a large chunck of a given web page, this saves a lot of bandwidth. A sample that could work is the following:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType etc, etc.
</IfModule>

See this article for some more advanced possibilities with .htaccess.

6) Optimize your images

Images are often responsible for more KB's then the rest of your web page, so they need to be optimized. Most importantly, make sure to use correctly-sized images. Secondly though, you can often further reduce the size of images dramatically by using compression tools that strip unnecessary data that you even didn't know was there. Even if you used the correct procedure to save images from Photoshop using Save for Web and Devices, a .png can still lose up to another 75% without visually being affected!!! Some tools that can help you to do so are:

Advanced users can also use techniques like image sprites and Base64 encoding.

7) Use a CDN

If you use a Content Delivery Network, your static files will not be served from the location of your web host, but from the global network of servers of your CDN provider. This ensures that users far away from the server receive their files from the nearest location, except for the HTML code that contains the content that often changes.

This sounds complicated, but actually it is quite easy to implement, and not even that expensive. It is not only good for sites operating globally, but also for sites in large countries.

8) Optimize CSS + Javascript

Especially modern sites often have many CSS and Javascript files, They all add up in size AND number of HTTP-requests. Also they often stop further loading of the page while they are executing. Luckily, there are techniques to overcome many of these issues:

  • Compress these files. This removes white space. While this affects readability of the code, it often saves dozens of percents in size.
  • Combine multiple files into one. Instead of many separate files, you only have one large CSS and one large JS file.
  • Use a defer or async attribute in the scripts to dealy execution.

Make sure your site still works as desired, sometimes some files need to be excluded. All this sounds nice, but it also can seem awfully complicated to implemented. Partially, you can perform these optimizations in your template, but what about the files that are not loaded from your template, but from the Joomla core, or extensions? Luckily, there is a nice solution: extensions! This brings us to item 9:

9) Speed optimization extensions

There are a number of extensions that can be a great help in speeding up your site. They especially address the issues described under item 8, while they often have some extra options under the Advanced tab. You should really try them out, results can be stunning! The best known are the following:

  • JCH-Optimize: Excellent for combining and compressing your files. It also offers option to set the defer and async parameter for Javascript. It is even capable of configuring images to sprites.
  • JBetolo: Similar to JCH-Optimize, while it also offers CDN-support, .htaccess tuning, and even Smush.it support.
  • Yireo ScriptMerge: The usual CSS and JS compression / combining capabilities. Extra are the options to base64-encode small images, plus support for jsmin-binary and WebP.
  • aeSecure: A new extension to watch out for. Mainly a security extension, but it also offers speed improvements.

10) Optimize for mobile devices

Even if your site loads fast on a desktop, it may not perform very well on mobile devices. If you use the Google Pagespeed tool to check the speed of your site, you may have seen a separate tab for mobile performance. Even with improved techniques like 4G, sites still may not load fast enough.

The key to improving this is to only load what is really needed. Hiding stuff with bootstrap classes like hidden-phone and hidden-tablet does not decrease bandwidth needed. One possibility is to use user-agent detection to check if you are on a mobile device, not just on a resized browser window. Having detected a mobile agent, you can then selectively disable module positions.

The NoNumber Advanced Module Manager is a tool that can be used to implement this.

Top