我应该为MySQL设置什么max_connection? [英] What max_connection should I set for MySQL?

查看:1117
本文介绍了我应该为MySQL设置什么max_connection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Linux Centos 上使用 MySQL 5.1.35 数据库。

Linux服务器< >

The Linux server has 2GB RAM with 14GB of disk space.

我已使用 Restlet 框架在Java中创建了webservices,其中 用户访问。

I have created webservices using Restlet framework in Java which has thousand user access.

我想为最大并发连接设置max_connection。

I want to set max_connection for maximum concurrent connections.

我应该设置什么 max_connection

So please suggest me that what max_connection should I set?

>

推荐答案

您需要计算MySQL引擎需要的内存。请参阅手动此处

You need to calculate the memory required by your MySQL engine. See manual here

如果您使用MYISAM表,那么您可以使用以下公式计算内存需求:

If you are using MYISAM tables then you can calculate memory requirement using following formula:

key_buffer_size + (read_buffer_size + sort_buffer_size) * max_connections = K bytes of memory 

理想情况下,此情况下不应超过2 GB。

Ideally this should not exceed 2 GB in your case.

配置参数取决于应用程序和查询的类型,但标准值可以是:

Configuration parameters depends on type of your application and querys, but standard values for you could be:

key_buffer_size = 1024MB + (read_buffer_size = 1MB + sort_buffer_size = 4MB) * 200 ~= 2GB

key_buffer_size 是一个全局变量, read_buffer_size和sort_buffer_size 是会话级参数。

key_buffer_size is a global variables whereas read_buffer_size and sort_buffer_size are session level parameters.

这篇关于我应该为MySQL设置什么max_connection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆