background preloader

Mb99

Facebook Twitter

Technology

Effective Java. Recently, I've re-read awesome java book Effective Java by Joshua Bloch. The book contains 78 independent items, discussing various aspects of programming in java. Something like mini-design patterns with emphasis on their pros and cons. Few notes from each item as a refresher. Item 1: Consider static factory methods instead of constructors Static factory methods have more informative names than constructorsSame parameters list could be appliedNot required to create new objects, could return cached instanceStatic factory methods could return object subtypeReduced verbosity for generics due to type inferenceClasses without public/private constructor can't be subclassed, but it is good, because it enforces to "favor composition over inheritance"Hard to distinguish from other static methods. To avoid confusion use common names like newIntance, valueOf, etc. Item 2: Consider a builder when faced with many constructor parameters Caution: Discussed singleton without lazy initialization.

Solaris Troubleshooting and Performance Tuning. Disk I/O Components What we blithely call a "Disk I/O" is actually made up of several components, each of which may have an impact on overall performance. These layers may be broken down as follows for a typical I/O operation: POSIX: Application calls a POSIX library interface. (These frequently map directly to system calls, except for the asynchronous interfaces. These latter work via pread and pwrite.) McDougall, Mauro and Gregg suggest that the best way to see if I/O is a problem at all is to look at the amount of time spent on library and system calls via DTrace.

For example, the DTrace Toolkit's procsystime utility tracks time spent on each system call. If the system call statistics reveal a problem, we should look at the raw disk I/O performance. Physical Disk I/O The primary tool to use in troubleshooting disk I/O problems is iostat. sar -d provides useful historical context. vmstat can provide information about disk saturation. Disk Utilization Disk Saturation Usage Pattern Page Cache. RESTful Web Services: A Tutorial. More than a decade after its introduction, REST has become one of the most important technologies for Web applications. Its importance is likely to continue growing quickly as all technologies move towards an API orientation. Every major development language now includes frameworks for building RESTful Web services.

As such, it is important for Web developers and architects to have a clear understanding of REST and RESTful services. This tutorial explains REST architecturally, then dives into the details of using it for common API-based tasks. While REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications, it is primarily used to build Web services that are lightweight, maintainable, and scalable. Features of a RESTful Services Every system uses resources. Representations Messages URIs Uniform interface Stateless Links between resources Caching Representations Listing One: JSON representation of a resource. Messages HTTP Request or. JVM Languages. JVM Languages JVM Languages Feature Articles On this site is archived all the content from Dr. Dobb's that was published on the Web through December 31, 2014.

The best tools available for creating, testing, and debugging code. Developing server-side apps with the popular Node.js framework can now be done with the full support of Visual Studio IntelliSense, debugging, and project management. Microsoft ports .NET to Linux and Macintosh and open-sources the entire stack. Using JavaScript and Node.js to quickly add new capabilities to IoT projects JVM Languages News A feature that automatically detects performance issues in every sixth Java application An open source cloud Dataflow SDK for Java Document Imaging SDK supports for JavaScript IntelliSense and 1D barcode reading An expansive code review and repository browsing tool Open source Java runtime from Azul Systems Slick functions for decompilation, debugging, (bug) detection, and refactoring Java development tool ends application server restarts.

A First RESTful Example - Java Web Services: Up and Running, 2nd Edition [Book] As befits a first example, the implementation is simple but sufficient to highlight key aspects of a RESTful web service. The implementation consists of a JSP (Java Server Pages) script and two backend JavaBeans that the JSP script uses to get the data returned to the client (see Figure 1-6). The data is composed of sage corporate predictions.

Here is a sample: There is an Ant script (see An Ant script for service deployment) that automates the deployment of this and other service examples. Here is a summary of the service parts and how the Ant script puts the parts together: In the predictions service, each prediction has an associated human predictor. How the Predictions Web Service Works When the predictions service is deployed to a web server such as Tomcat, the server translates the JSP script predictions.jsp (see Example 1-6) into a servlet instance. Example 1-6. As requests come to the JSP script, the script first checks the request’s HTTP method. Example 1-7.

Example 1-8. Appears. Lambda Expressions in Java 8. 7. Memory : Stack vs Heap. Here is a short program that creates its variables on the stack. It looks like the other programs we have seen so far. #include <stdio.h> double multiplyByTwo (double input) { double twice = input * 2.0; return twice; } int main (int argc, char *argv[]) { int age = 30; double salary = 12345.67; double myList[3] = {1.2, 2.3, 3.4}; printf("double your salary is %.3f\n", multiplyByTwo(salary)); return 0; } double your salary is 24691.340 On lines 10, 11 and 12 we declare variables: an int, a double, and an array of three doubles. These three variables are pushed onto the stack as soon as the main() function allocates them. When the main() function exits (and the program stops) these variables are popped off of the stack. Similarly, in the function multiplyByTwo(), the twice variable, which is a double, is pushed onto the stack as soon as the multiplyByTwo() function allocates it.

Here is another version of this program that allocates all of its variables on the heap instead of the stack: Virtual Panel: Using Java in Low Latency Environments. Java is increasingly being used for low latency work where previously C and C++ were the de-facto choice. InfoQ brought together four experts in the field to discuss what is driving the trend, and some of the best practices when using Java in these situations. The participants: Peter Lawrey is a Java consultant interested in low latency and high throughput systems. He has worked for a number of hedge funds, trading firms and investment banks. Martin Thompson is a high performance and low latency specialist, with over two decades working with large scale transactional and big-data systems, in the automotive, gaming, financial, mobile, and content management domains. Todd L. Dr Andy Piper recently joined Push Technology as Chief Technology Officer, from Oracle. The Questions: What do we mean by low latency?

Q1: What do we mean by low latency? Lawrey: A system with a measured latency requirement which is too fast to see. Q3. Q4. Q5. Q6. Lawrey: Waiting for IO of some type. Q7. Q9. Q10. Todd L. The LMAX Architecture. LMAX is a new retail financial trading platform. As a result it has to process many trades with low latency. The system is built on the JVM platform and centers on a Business Logic Processor that can handle 6 million orders per second on a single thread. The Business Logic Processor runs entirely in-memory using event sourcing. The Business Logic Processor is surrounded by Disruptors - a concurrency component that implements a network of queues that operate without needing locks. During the design process the team concluded that recent directions in high-performance concurrency models using queues are fundamentally at odds with modern CPU design. Over the last few years we keep hearing that "the free lunch is over"[1] - we can't expect increases in individual CPU speed.

So to write fast code we need to explicitly use multiple processors with concurrent software. So I was fascinated to hear about a talk at QCon London in March last year from LMAX. Overall Structure Tuning performance. Disruptor by LMAX-Exchange. Download here... Discussion, Blogs & Other Useful Links Presentations Introduction to the Disruptor Read This First To understand the problem the Disruptor is trying to solve, and to get a feel for why this concurrency framework is so fast, read the Technical Paper.

And now for some words from our sponsors... What is the Disruptor? LMAX aims to be the fastest trading platform in the world. The Disruptor is the result of our research and testing. This is not a specialist solution, it's not designed to work only for a financial application. It works in a different way to more conventional approaches, so you use it a little differently than you might be used to. If you prefer real, live people explaining things instead of a dry paper or content-heavy website, there's always the presentation Mike and Martin gave at QCon San Francisco.

What's the big deal? It's fast. Note that this is a log-log scale, not linear. Great What do I do next? FUN THINGS TO DO WITH KIDS IN NJ - Kids attractions NJ. Offloading data from the JVM heap (a little experiment) Last time, I wrote about the possibility of using Linux shared memory to offload cacheable/reference data from the JVM. To that end I wrote a small Java program to see if it was practical. The results were better (some even stranger) than I had expected. Here's what the test program does: Create a bunch of java.nio.ByteBuffers that add up to 96MB of storageWrite ints starting from the first buffer, all the way to the last one - that's writing a total of 96MB of some contrived dataFor each test, the buffer creation, writing and deletion is done 24 times (JIT warm up)For each such test iteration, measure the memory (roughly) used in the JVM heap, the time taken to create those buffers and the time taken to write 96MB of dataObviously, there are things here that sound fishy to you - like why use ByteBuffers instead of just writing to an OutputStream or why write to the buffers in sequence.

Interpretation of the results: WK's High Frequency Trading Blog. The response to my first few posts has been much larger than I’d imagined and I’d like to thank everyone for the encouragement. If you’re interested in building a trading system I recommend first reading my previous post on general ideas to keep in mind. My first really technical post will be on how to build a limit order book, probably the single most important component of a trading system. Because the data structure chosen to represent the limit order book will be the primary source of market information for trading models, it is important to make it both absolutely correct and extremely fast. To give some idea of the data volumes, the Nasdaq TotalView ITCH feed, which is every event in every instrument traded on the Nasdaq, can have data rates of 20+ gigabytes/day with spikes of 3 megabytes/second or more.

The individual messages average about 20 bytes each so this means handling 100,000-200,000 messages per second during high volume periods. Eden Space. Hi All, Jay SenSharma JVM is the heart of any Java based Application Server. We face most of the issues deu to incorrect JVM tunning. It is very important to understand the Overall architecture of the JVM in order to trouble shoot different JVM tunning related issues.Here we are going to discuss the Architecture and the Major parts of a Java Process And the Java Heap Division. The Following Diagram is just a basic overview of a Java Process in a 2 GB process Size Machine. Java Process Architecture Diagram In the above diagram we will find different partitions of a Java Process. 1). 2). 3). 4). 5). Could not reserve enough space for object heap Many times while providing some value for the Max Heap or Max Perm we get the following kind of error: In above case users should decrease JVM process size by decreasing the heap or permgen size or the Xss value.

The maximum theoretical heap limit for the 32-bit JVM is 4G. Why to choose a 64-bit JVM? Eden Space: Survivor Spaces: Example: Native Area: Learn C The Hard Way. Troubleshooting Guide for Java SE 6 with HotSpot VM. Frequently Asked Questions About the Java HotSpot VM. This FAQ answers common questions about Java HotSpot Technology and about performance in general.

Unless otherwise noted, all information on this page applies to both the HotSpot Client VM and the HotSpot Server VM as of Java SE version 1.4. General Memory and Garbage Collection JIT Compiler 64-bit Java Multithreaded Applications Performance Benchmarking the Java HotSpot VM General What command-line options does the Java HotSpot VM provide for performance tuning? See the document Java HotSpot VM Options . Are there any resources for troubleshooting HotSpot issues? For more in-depth troubleshooting discussion beyond the scope of this FAQ, please see the Java Trouble-Shooting and Diagnostic Guide I can't get profiling to work, what should I do?

First, make sure you are running with -agentlib:hprof and try -agentlib:hprof=help to see the different kinds of profiling available. I keep running out of file descriptors, what should I do? Certain applications will use a lot of file descriptors. -Xmx-Xms-Xmx. Tuning Garbage Collection for Mission-Critical Java Applications - Tuning Guidelines for Java Garbage Collection, Part 1 « mgm technology blog.

I recently had the opportunity to test and tune the performance of several shop and portal applications built with Java and running on the Sun/Oracle JVM, among them some of the most visited in Germany. In many cases garbage collection is a key aspect of Java server performance. In the following article we take a look at the state-of-the-art advanced GC algorithms and important tuning options and compare them for diverse real-world scenarios.

Seen from the point of Garbage Collection, Java server applications have wide varying requirements: Some are high-traffic applications serving a huge amount of requests and creating a huge amount of objects. Sometimes, moderate-traffic applications using wasteful software frameworks do the same thing. In many cases you will find a combination of several of these requirements with different priorities. Out-of-the-Box GC Performance JVMs have improved a lot but still cannot do your job of optimizing the runtime for your application. 1. 2. 3. 4. 5. 6. Java 8 Lambda Expressions & Streams.