Arganzheng's Blog

stay hungry, stay foolish

Java Heap OOM问题

今天线上API机器出问题了,很多机器告警,tomcat重启不久又挂掉。 看了一下日志,发现是OOM了: java.lang.OutOfMemoryError: Java heap space Dumping heap to java_pid21673.hprof ... Heap dump file created [1934558576 bytes in 8.670 secs] [Unloading class sun.reflect.GeneratedConstructorAccessor17] 2013-7-28 12:03:35 org.apache.tomcat.util.http.Parameters processParameters 320305...

配置文件串串SHOW

2009–18 星期四 热 一、有哪些配置文件 入口配置文件:web.xml;由web或应用服务器为每个web项目加载的配置文件。 应用上下文:包括web框架特有配置文件:如struts的struts-config.xml(或struts2的struts.xml)文件和SpringMVC的${dispatcherServletName}-servlet.xml配置文件。和Spring的配置文件,一般按层划分为业务层xxx-service.xml和持久层xxx-data.xml。 说明:事实上,web层配置文件也可以使用Spring配置,这就是所谓的框架整合。 二、配置文件的加载过程 web.xml是所有配置文件的入口配置文件,Tomcat在启动...

负载均衡

高性能高可用性的系统一般会有多层次的负载均衡(High-performance systems may use multiple layers of load balancing)。负责均衡的实现机制有硬件和软件两种。下面我们以top down的方式一层层介绍下去。 总体来说负责均衡分为无状态服务负载均衡,以及有状态的数据负载均衡两类。前者(比如web server,app Server)由于是无状态的,所以backen-server是对等的,可以路由到任何一台机器,路由的策略一般是业务无关的(灰度除外),比如backen-server的负载情况。而对于有状态的数据负载均衡(比如cache,MQ或者DB),对等是基本不可能的,因为数据存放多份带来的写压力以及一致性...

如何使用tomcat高效调试

1. 使用maven tomcat插件快速部署和启动web工程: mvn tomcat:run 如果要调试,可以先在命令行设置如下环境变量: Windows: set MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 Linux: export MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 然后在eclipse中就可以链接8000端口(可随意设定)进行调试了。 TIPS 如果是tomcat7的话,需要制定版本号:mvn tomcat7:run。 2. 使用E...

如何在远程Linux机器上执行Shell命令

通常我们需要写个shell脚本然后放上服务器上执行。一般的步骤是先登陆上服务器,然后将shell脚本上传到服务器的某个目录下,最后是执行这个脚本。然而shell本身是支持远程执行的。 可以使用如下命令: ssh user@server bash < /path/to/local/script.sh 在远程机器上运行一段脚本。这条命令最大的好处就是不用把脚本拷到远程机器上。 如果你只是想执行on line command,那么可以使用管道: echo "date" | ssh user@server bash 当然,远程执行的前提其实是要先ssh到服务器的,需要身份验证。可以使用except或者ssh public key来实现免密码登陆。这样就...

域名解析过程及其相关配置

/etc/host.conf The host.conf File The central file that controls your resolver setup is host.conf. It resides in /etc and tells the resolver which services to use, and in what order. Options in host.conf must occur on separate lines. Fields may be separated by white space (spaces or tabs). A hash sign (#) introduces a comment tha...

使用Spring-Security进行登录控制的session问题

这边文章Spring Security Form Login Using Database对Spring Security做了非常简单明了的介绍。而且有一个可以down下来运行的示例工程。笔者试验了一下,发现一些有意思的问题。 访问http://localhost/SpringMVC/login,填写用户名和密码,点击登录按钮,发生如下请求: Request URL:http://localhost/SpringMVC/j_spring_security_check Request Method:POST Status Code:302 Moved Temporarily Request Headers Accept:text/html,applicatio...

Restful Spring MVC

Spring MVC本身对Restful支持非常好。它的@RequestMapping、@RequestParam、@PathVariable、@ResponseBody注解很好的支持了REST。18.2 Creating RESTful services 1. @RequestMapping Spring uses the @RequestMapping method annotation to define the URI Template for the request. 类似于struts的action-mapping。 可以指定POST或者GET。 2. @PathVariable The @PathVariable method paramete...

Spring的Bean Scopes

Spring一共支持5种bean scopes,其中3种需要web-aware ApplicationContext。Bean Scopes out of the box, the Spring Framework supports exactly five scopes (of which three are available only if you are using a web-aware ApplicationContext). singleton Scopes a single bean definition to a single object instance per Spring IoC container. ...

Spring的Bean Scopes实现机制源码剖析

关于Spring的bean scopes,在我的上一篇文章 Spring的Bean Scopes 已经做了详细的介绍,这里我们探讨一下Spring的bean scopes底层是怎么实现的。 通过下面这行简单的配置: <bean class="me.arganzheng.study.scope.FooUser" scope="request"> <aop:scoped-proxy /> </bean> 为什么我们就可以让FooUser每次请求都生成新实例,而且可以注入到生命周期比它长的singleton bean中呢? public class FooService{ @Autowired FooUse...

×