Real-world Java 4 beginners. Dima, Superfish github.com/dimafrid



Similar documents
PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

No no-argument constructor. No default constructor found

Liferay Performance Tuning

Java Monitoring. Stuff You Can Get For Free (And Stuff You Can t) Paul Jasek Sales Engineer

Operations and Monitoring with Spring

Java EE Web Development Course Program

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Effective Java Programming. measurement as the basis

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

TDA - Thread Dump Analyzer

Moving beyond hardware

WEBLOGIC ADMINISTRATION

WebSphere Server Administration Course

IBM WebSphere Server Administration

Performance Optimization For Operational Risk Management Application On Azure Platform

Systems Integration in the Cloud Era with Apache Camel. Kai Wähner, Principal Consultant

Top 10 reasons your ecommerce site will fail during peak periods

Monitoring applications in multitier environment. Uroš Majcen A New View on Application Management.

Java 2 Web Developer Certification Study Guide Natalie Levi

Java SE 8 Programming

HP OO 10.X - SiteScope Monitoring Templates

Why Threads Are A Bad Idea (for most purposes)

An Oracle White Paper September Advanced Java Diagnostics and Monitoring Without Performance Overhead

Tuning Your GlassFish Performance Tips. Deep Singh Enterprise Java Performance Team Sun Microsystems, Inc.

Tomcat Tuning. Mark Thomas April 2009

B M C S O F T W A R E, I N C. BASIC BEST PRACTICES. Ross Cochran Principal SW Consultant

Understanding Hardware Transactional Memory

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

How To Use Java On An Ipa (Jspa) With A Microsoft Powerbook (Jempa) With An Ipad And A Microos 2.5 (Microos)

Java Performance. Adrian Dozsa TM-JUG

Java Troubleshooting and Performance

Agility Database Scalability Testing

Essentials of Java Performance Tuning. Dr Heinz Kabutz Kirk Pepperdine Sun Java Champions

The end. Carl Nettelblad

Japan Communication India Skill Development Center

Cognos8 Deployment Best Practices for Performance/Scalability. Barnaby Cole Practice Lead, Technical Services

CSE 403. Performance Profiling Marty Stepp

Monitoring and Alerting

BEAJRockit Mission Control. Using JRockit Mission Control in the Eclipse IDE

Java SE 7 Programming

How To Test A Web Server

High-Availability. Configurations for Liferay Portal. James Min. Senior Consultant / Sales Engineer, Liferay, Inc.

THE BUSY DEVELOPER'S GUIDE TO JVM TROUBLESHOOTING

Delivering Quality in Software Performance and Scalability Testing

Software infrastructure for Java development projects

Azul Compute Appliances

An Overview of Java. overview-1

Extreme Performance with Java

SOA Solutions & Middleware Testing: White Paper

Monitoring Java enviroment / applications

Optimize GlassFish Performance in a Production Environment Performance White Paper February Abstract

Monitoring HP OO 10. Overview. Available Tools. HP OO Community Guides

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

Garbage Collection in the Java HotSpot Virtual Machine

Multithreading and Java Native Interface (JNI)!

3 Techniques for Database Scalability with Hibernate. Geert Bevin - SpringOne 2009

Apache Traffic Server Extensible Host Resolution

Open Source and Commercial Performance Testing Tools

A Practical Method to Diagnose Memory Leaks in Java Application Alan Yu

<Insert Picture Here> Java Application Diagnostic Expert

Java VM monitoring and the Health Center API. William Smith

A Tool for Evaluation and Optimization of Web Application Performance

Tutorial: Load Testing with CLIF

Java Servlet 3.0. Rajiv Mordani Spec Lead

CS11 Java. Fall Lecture 7

Load Testing Ajax Apps using head-less browser tools. NoVaTAIG April 13, 2011 Gopal Addada and Frank Hurley Cigital Inc.

Performance Monitoring and Tuning. Liferay Chicago User Group (LCHIUG) James Lefeu 29AUG2013

CSCI E 98: Managed Environments for the Execution of Programs

Database Applications Recitation 10. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Replication on Virtual Machines

Transaction Performance Maximizer InterMax

GUI Test Automation How-To Tips

Web Applications. For live Java training, please see training courses at

Application Security

COS 318: Operating Systems

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

WEBSPHERE APPLICATION SERVER ADMIN V8.5 (on Linux and Windows) WITH REAL-TIME CONCEPTS & REAL-TIME PROJECT

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Japan Communication India Skill Development Center

Oracle JRockit Mission Control Overview

A Comparative Study on Vega-HTTP & Popular Open-source Web-servers

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

PHP vs. Java. In this paper, I am not discussing following two issues since each is currently hotly debated in various communities:

Applets, RMI, JDBC Exam Review

Managing Data on the World Wide-Web

SAP HANA SAP s In-Memory Database. Dr. Martin Kittel, SAP HANA Development January 16, 2013

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Learning GlassFish for Tomcat Users

What Is Specific in Load Testing?

Learning More About Load Testing

Kotlin for Android Developers

Transcription:

Real-world Java 4 beginners Dima, Superfish github.com/dimafrid

Real world Hundreds of computations per second Each computation of sub-second latency Massive IO Lots of data In Web/Trading/Monitoring/Cellular/etc./etc. Squeezing every bit of juice out of HW

Real world case study Google does 10B searches a day keeping entire Web in the belly Twitter does 3000 tweets a minute (fanning out to 600K users) Netflix is responsible for 30% of US traffic in certain hours

Real world case study Superfish 150M requests a day 150K requests a minute @ peak time Must have sub-500ms response time ~0.5B data records 300K KPIs a minute Hundreds of machines

Whatever you desire : Core stuff (IO, concurrency, GC) Application development (frameworks/open source recommendations/best practices) Monitoring (what, tools)

Core Java stuff - concurrency All about parallel utilization of HW resources Basic multi-threading: wait() & notify() java.util.concurrent why? Introduced by Doug Leah in Java 5 Thread pools Atomic counters Lock-less data structures Smart synchronizers Futures

Core Java stuff - concurrency Thread pools Creating thread is expensive (memory allocation/ forking /GC/book-keeping) Solution: pre-create (pooling) Atomic counters ++cnt is not thread-safe operation Lock-less data structures Locking is expensive Smart synchronizers

Core Java stuff - IO Readers/writers for EVERYTHING: file/socket/string/object (serialization) Comprehensive javadoc Buffering Read in advance Making IO effective in terms of system calls

Core Java stuff - IO BIO (blocking IO) Wait until data is available NIO (non-blocking IO) Introduced relatively late in Java, somehow still lagging Old & good idea of notifying whenever data is available Single reading loop calling back upon data availability BIO vs. NIO real life example: BIO: hundreds of threads, machine dead NIO: 6 data processing threads BIO straightforward, NIO harder to implement

Core Java stuff - GC There is no explicit memory deallocation in Java Garbage collector frees allocated memory Poorly tuned GC in heavy load env = major contributor to high latency Definitely an expertise

Core Java stuff - GC Common model Reach-ability from roots (static & threads) Based on assumption that some objects are more durable than others New and old gens, survivals, different collectors G1 New No personal experience, so won't b**s you

Core Java stuff - GC Tuning Dozens of parameters Understand your memory patterns! High-throughput/low-pause oriented collectors Benchmarks unavoidable Diagnostics: GC log

Core Java stuff Memory Couldn't resist this one: No memory leaks in Java - good reason to terminate Even w/o esoteric scenarios, creating a memory leak in Java is trivial More memory is better - like saying more butter is better For better taste yes For avoiding a coronary - no

Core Java stuff others JDBC Generics Data structures (java.util) know your data structure under-the-hood really heavy-stuff of tuning hash maps, for example: need to understand the implementation Etc. etc.

Application development A set of frameworks/toolkits that essentially Provide integration with other SW Make life easier no need to write everything yourself Speed of development Let's talk about the most-wanted of Java app development

Application development - Spring Essentially an integration framework Origin lays in IoC/dependency-injection model within a container of Spring beans Spring bean is an instance of Java class declared in container definition Deriving population/initialization from declared dependencies On top of the container, there are integrations: Remoting, DB, unit testing, scheduling And messaging, AOP, etc. etc. etc.

Application development - Spring <context:component-scan base-package="com.superfish.fbeng"/> <context:annotation-config/> <bean id="placeholderconfig" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath*:config/*.properties</value> </list> </property> </bean> <bean id="statspersister" class="com.superfish.realtime.services.search.statspersister"> <property name="sessionfactory" ref="statssessionfactory"/> <property name="persistonceeveryx" value="1"/> <property name="peristthreadcount" value="10"/> </bean>

Application development - Spring @Repository public class PhotoDaoImpl extends BaseJpaDaoImpl<String, PhotoEntity> implements PhotoDao {.. @Resource(name = "datasource") private DataSource ds; @Autowired private PhotoDao imagedao;.. }

Application development - Spring Well-written (at least whatever I hacked) Rich Convenient Spend some time learning the internals (especially DB-related stuff) Every recruiter recognizes a Spring word...

Application development - REST How do you make 2 machines talk to each other (HTTP implied)? SOAP Like calling a method Attempts to cover everything Like everything that wants to be perfect - dead

Application development - REST REST emerged Apart from being a Ph.D. material, it's essentially like a page exchange over HTTP Simple because it's modeled after HTTP Implementations (REST is merely an idea with standardization): Wink (personal experience) Jersey RestEasy

Application development - JPA Probably most important counter-part of any application today is DB JPA bridges between OO world and relational DB

Application development - Servers The basic component of Java web server is servlet container Servlet container is a place to put web applications Web application is a collection of servlets (and everything needed to run their code) and mapping of URLs to those servlets:

Application development - Servers tau.me:9090/rwj4b/search?student=mark%20zuck erberg rwj4b web app name search path of reqest student=mark%20zuckerberg - query params

Application development - Servers <servlet> <servlet-name>dummy</servlet-name> <servlet-class>dummyservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>dummy</servlet-name> <url-pattern>search/*</url-pattern> </servlet-mapping>

Application development - Servers public class DummyServlet extends HttpServlet { } protected void doget(httpservletrequest req, HttpServletResponse resp) throws ServletException, IOException { String student = req.getparameter("student"); resp.getwriter().write(student + " digs real life java"); }

Application development VM (dynamic) languages Scala Groovy Jython JRuby

Application development - management Not really directly related to Java Version management ClearCase (rolls royce, but expensive and requires management) Subversion (oldie, mediocre, choice of many) Git (version management is about branching, and that's what it does best; complicated as hell for non-vanilla use-cases) Project management Don't really have any experience with anything but Maven Transparent dependency management

Application development - practice If you think you're missing a very important infrastructure: Don't write Find an open-source Understand how it works and then use/throw away and write yourself Apache.org: richness, quality your first address Google open-sources state-of-the-art SW Collections (academic stuff) Gson Unit-test (Junit, NG something) not compulsively

Monitoring When you deal with hundreds of millions of applicative operations, you have to understand what's going on Local monitoring System profiling Visualization

Monitoring Local (Java-level) Thread dumps GC logs Memory distribution Applicative logging Good logging requires thorough thinking as it's a valid basis for further analysis Bad logging kills performance JMX Built-in ability to plug-in and access your custom code Widely used for diag