`
astroxl
  • 浏览: 54270 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Java Debian Tuning

    博客分类:
  • Java
阅读更多

From JavaDebianTuning

Debian is a stable easy to maintain platform for Java Web Applications. However if you start using some caching frameworks, you may need to do some JVM tuning and here's the information you need to know.

Read this and to the point where you understand that a 32-process on Linux only has 2GB of addressible space. In fact, back in 1999, Linus decreed that 32-bit Linux would never, ever support more than 2GB of memory. "This is not negotiable."

Stacks are memory chunks used for saving variables and passing parameters when calling functions. It's a low level implementation detail, but the important thing to know is that each thread in each process must have it's own stack. Big stacks add up quickly as in the case of tomcat and most web servers where many threads are used to serve requests. Stacks for threads all come out of the same address space, so if you only used memory for stacks of threads you could have 1024 threads with 2MB stacks. In fact in Debian Sarge, there is no way to reduce the amount of memory allocated for the stack of a thread. [1] [2] [3] . Understand that this is not java specific, the same limitation applies to c programs.

Now that we have some fundamental stuff down, it's easy from here. Say you have 2G of Memory and want to use as much memory as possible for your cash for performance considerations. The objects in the cash will be stored in the heap memory. I think you should calculate how much memory you should use with the following formula.

 

HeapMemory = ProcessAdressSpace - ThreadMemory - PermGen - JVM

If you're running 32-bit, you can only see 2G max.

 

ProcessAdressSpace = 2G

If you web app is like mine, you'll need 100 threads. Have some librarys that may create threads, tack on another 100 to be safe. 200 threads X 2Mb/Thread = 400M

 

ThreadMemory = 400M

PermGen is where your defined classes go. Since you use alot of frameworks and have lots of classes, you should set this to 128M

 

PermGen = 128M

JVM is relatively small, but you need to give it room so that it can work quickly.

 

JVM = 256M

With those parameters, HeapMemory should not exceed 1264M! Anything more and you're going to slow down your application more than the cache is speeding it up, or you'll introduce nasty a OutOfMemoryException that will drive you crazy. Here's the parameters you want to use.

 

java -Xmx1264M -XX:MaxPermSize=128m ...

If you upgrade to etch, and set the stack size to 1MB (not recommending without extensive testing), then you can reclaim another 200MB for the heap.

 

java -Xmx1464M -XX:MaxPermSize=128m -Xss1M ...

You can test your deployment platform and play with the parameters with this java program.

 

public class ThreadLimit
extends Thread {
    private static boolean stop = false;

    public void run() {
        try {
            int x = 0;
            while (true) {
                x++;
                Thread.sleep(100);
                if (stop) return;
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] argv)
    throws InterruptedException {
        long threads = 0;
        try {
            while (true) {
                Thread t = new ThreadLimit();
                t.start();
                threads++;
            }
        } catch (Error e) {
            stop = true;
            System.out.println("Died with "+threads+" threads.");
        }
    }
}

[#1] pthread_attr_setstacksize is called from jdk1.6.0 (rc1) src/launcher/java_md.c :1735

[#2] http://pauillac.inria.fr/~xleroy/linuxthreads/faq.html#E (see question E.5) - Only LinuxThreads .8 has the ability to reset the stack size using pthread_attr_setstacksize.

[#3] cat /usr/share/doc/libc6/README.linuxthreads.gz | gunzip | more - that's right, Sarge comes with .7.

See JavaHeapUtilization AMD64

 

Links

 

 

分享到:
评论

相关推荐

    debian安装java环境文档

    "debian安装java环境文档" 在 Debian 环境中安装 Java 环境是一个复杂的过程,涉及到多个组件的安装和配置,本文档将指导您完成 Debian 下的 Java 环境安装,包括 JDK、Tomcat 和 MySQL 的安装和配置。 一、JDK 的...

    mysql-connector-java-Debian

    在Debian操作系统环境下,安装和使用MySQL Connector/J对于开发和部署基于Java的数据库应用至关重要。本篇文章将深入探讨这个主题,介绍如何在Debian系统中配置和使用MySQL Connector/J。 首先,MySQL Connector/J...

    Linux(Debian)上编译运行Java程序入门.docx

    在Linux(Debian)系统上编译和运行Java程序可能会对初学者来说有些陌生,但遵循正确的步骤,这个过程其实相当简单。以下是一个详细的指南,帮助你从零开始熟悉这个流程。 首先,确保你的系统已经安装了Java ...

    debian.11.3+debian-bullseye+debian-buster

    这个压缩包文件包含了三个不同版本的Debian操作系统镜像:debian.11.3、debian_bullseye和debian_buster。每个版本都有其独特的特性和改进,下面将详细讨论这些版本。 首先,我们来看`debian.11.3`,也被称为Debian...

    oracle-java8, Debian的最新 Java 8软件包.zip

    oracle-java8, Debian的最新 Java 8软件包 简介用于Debian的Java 8软件包。支持Debian版本目前,软件包已经在Debian版本上进行了测试:扩展 i386/amd64jessie i386/amd64wheezy i386/amd64我没有在Ubun

    debian参考手册,debian管理员使用

    ### Debian参考手册知识点详解 #### 一、简介 **Debian参考手册**是一份非常详尽的指南,专为Debian系统的用户和管理员设计。它不仅涵盖了Debian的基础概念、安装指南,还深入探讨了软件包管理、系统优化、网络...

    Debian系统管理员参考手册 The Debian Administrator’s Handbook

    《Debian系统管理员参考手册》是由Raphaël Hertzog和Roland Mas撰写的一本详细的手册,主要面向希望深入了解Debian系统的管理员和用户。Debian是一个基于Linux内核的操作系统,以其强大的社区支持、多平台兼容性和...

    mysql-connector-java_8.0.13-1debian9_all.deb

    mysql-connector-java_8.0.13-1debian9_all.deb,一个linux的驱动

    debian (Debian GNU/Linux下的小康生活)

    ### Debian GNU/Linux 知识点概述 #### 一、Debian GNU/Linux 概览 **1.1 GNU/Linux** **1.1.1 GNU 项目** - **起源与发展**: GNU 项目始于 1983 年,由 Richard Stallman 发起。该项目旨在创建一套完全自由的...

    debian gnu linux debian gnu linux

    debian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linux

    Debian Linux服务器资料

    虽然给定内容中关于Java JDK的安装部分不完整,但在Debian上安装Java通常涉及以下步骤: 1. **查找可用的JDK包**:使用`apt-cache search openjdk`或`apt-cache search java`来查找系统中的Java相关包。 2. **安装...

    Debian Packaging Tutoria(Debian 打包教程)

    Debian是Linux世界中一个非常重要的发行版,其软件包管理系统是其核心特色之一。Debian打包教程,正如标题所示,是一份详细指导如何创建和维护Debian软件包的文档。教程涵盖了从基础到高级的各种知识,对于想要为...

    debian软件包sources.list

    linux-debian软件安装包sources.list 路径 /etc/apt # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie main # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ ...

    Debian Packer 1.2.1 For Windows x86 (Windows 平台下首款能对 Debian 数据包直接解包、封包的工具软件)

    **Debian Packer 1.2.1 for Windows x86** 是一款专为Windows用户设计的工具,它填补了Windows平台下处理Debian数据包的空白,允许用户直接对Debian包进行解包和封包操作。这款软件是Windows环境下的首创,极大地...

    Debian 7 和 Debian 8 用户安装 Java 8的方法

    本篇文章将详细指导Debian 7 "Wheezy"和Debian 8 "Jessie"用户如何安装Oracle Java 8。 首先,我们来看Java 8的主要特性。Oracle Java 8引入了Lambda表达式,这是Java语言的重大革新,它允许程序员以简洁的方式处理...

    debian package hwoto

    根据给定的文件信息,以下是对“创建Debian安装包”的详细解读与相关知识点的深入探讨。 ### Debian Package Creation: An In-depth Overview #### 标题解析:Debian Package Howto(Debian包如何制作) 标题揭示...

    Debian中下载DLBD 46G镜像的步骤办法(采用jigdo方式)

    在本文中,我们将详细介绍如何在Debian系统中下载大型的DLBD(Debian Live and Debian Installer Binary Distribution)镜像文件,特别是使用jigdo工具来高效地完成这一任务。jigdo是一种有效的下载方法,它允许用户...

    Debian 7 Wheezy升级到Debian 8 Jessie的具体步骤.docx

    Debian 7 Wheezy升级到Debian 8 Jessie的具体步骤 Debian 8 Jessie 于 2015 年 4 月 25 日正式发布,经过了长达两年的开发后,Debian 团队宣布 8.0 版本的发布,代号为 Jessie 。Debian 的升级过程相对来说比较容易...

    Debian 11 操作系统(debian-11.2.0-amd64-netinst.iso)

    Debian 11 操作系统(debian-11.2.0-amd64-netinst.iso),网络安装,用于 64 位 PC(amd64)。 Debian GNU/Linux 是一个操作系统及自由软件的发行版,它是由一群自愿付出时间和精力的用户来维护并更新的。

    debian source.list

    debian source.list **** http://ftp2.jp.debian.org *** http://debian.okey.net *** http://mirror.dlut.edu.cn http://www.91duoduo.com/jishu/linux_xx.html?noid=afblfi

Global site tag (gtag.js) - Google Analytics