SDN Journal Authors: Elizabeth White, Yeshim Deniz, Liz McMillan, Pat Romanski, TJ Randall

Related Topics: Java IoT, Industrial IoT, Open Source Cloud, Machine Learning , Apache, SDN Journal

Java IoT: Article

Tracing Black Boxes III: Solr Query Performance Tuning

Solr Query Performance Tuning

Solr Server provides JMX statistics that show performance details such as query speed and cache hit/miss rates in a macro level, which James talked about in a previous post. However, it might be tough to trace how a particular operation; for example: how a specific query fared in the system. This week, I'd like to introduce TraceView's latest support for Solr Server, which provides breakdown of each operation, enabling more precise performance monitoring and troubleshooting.

How does Solr work, anyway?

Requests made to Solr Server can be roughly divided into 3 categories: queries, data indexing/update, admin operations (check server health/log, optimize server etc). Requests made to Solr server first go through the SolrDispatchFilter that looks up the corresponding Solr Core (a running instance of index/dataset along with configurations) and handler. The retrieved SolrCore and handler are then used to process the request. For SearchHandler, it is further broken down into smaller SearchComponents (for example, querying, highlighting results, calculating statistics etc).

Take note that since version 4, Solr added distributed capabilities in Solr called SolrCloud, which enable highly available, fault tolerant cluster of Solr servers. Index/dataset is no longer hosted on a single Core/instance. Instead, it is constructed by several shards, each as a disjoint subset of the documents in the index, and each shard can be backed by multiple cores, which are replicas of each other.

For caching, Solr uses several built-in classes (LRUCache, FastLRUCache, LFUCache) for various aspects (field, filter, query result, document etc). They are implemented as in-memory caches to allow quicker operations. The configurations of caches can be found in the Query section of solrconfig.xml.

Indexing and updates can be slow, and certainly compete for resources, but they can be done asynchronously. Admin operations can be slow as well, but they are typically one-time events, or not performance sensitive. Queries are typically the most important operation, as they live in the critical path for the user. TraceView monitor activities on each of the classes that correspond to these actions and their components to extract run-time information on each of the modules described. Let's take a look at an example.

Tracing Queries
A trace follows the path of a request through the entire application. For example, a trace below shows the breakdowns of a query operation:


There's a lot more going on that just searching the index for the given phrase!

Solr has a lot more functionality than just returning a list of documents that match a query. In particular, this query's time is actually dominated by "highlight.process" (highlight matching phrases in the query result) and "ResponseWriter.write" (write data to the response stream). We could speed up this request by nearly 2x by just disabling the highlighter in config!

The other interesting information here is what's not visible. This query didn't hit a cache of any sort. Even for highly variable search terms, the cache can help with users paging through longer lists or sharing links. In this case, TraceView found several cache miss events on "documentCache" that contribute to longer load time.


Pre-warming the cache could help with this, or if this is a common term, it's possible that it's being evicted due to small cache size. We could verify this by checking the JMX statistics for cache eviction rates and adjusting the cache size in our config, if necessary.

Beyond Solr
Instrumentation on Solr Server does not only give an isolated view of how Solr performs, it also draws a complete picture of all the interactions with other applications/systems. For example, below is trace of a query request issued a typical Drupal search page backed by Solr service runs on a different host:


We can trace the request handling all the way through the Apache server, Drupal modules, and Solr handling all in one trace. In particular, this tracks requests even when the app and Solr are running on different machines, which allows you to track down issues where the application calls the Solr server incorrectly.

More Stories By Patson Luk

A Java developer who has spent the better part of the last decade working on financial services applications with companies from HSBC to Mobilearth and Parasoft, Patson is experienced in various aspects of computer systems, from large scale enterprise banking system to lightweight mobile payment solutions. He now leads Java instrumentation and tool development for the TraceView product at AppNeta. Patson's focus is on using java bytecode manipulation technologies to gain greater visibility into the full spectrum of Java based technologies. This includes higher level application frameworks from Spring and Struts to Webflow, AppServers from TomCat to JBoss, and Databases from MySQL to Oracle. He's also writes frequently on the AppNeta blog - www.appneta.com/blog

CloudEXPO Stories
Your job is mostly boring. Many of the IT operations tasks you perform on a day-to-day basis are repetitive and dull. Utilizing automation can improve your work life, automating away the drudgery and embracing the passion for technology that got you started in the first place. In this presentation, I'll talk about what automation is, and how to approach implementing it in the context of IT Operations. Ned will discuss keys to success in the long term and include practical real-world examples. Get started on automating your way to a brighter future!
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next-gen applications and how to address the challenges of building applications that harness all data types and sources.
Lori MacVittie is a subject matter expert on emerging technology responsible for outbound evangelism across F5's entire product suite. MacVittie has extensive development and technical architecture experience in both high-tech and enterprise organizations, in addition to network and systems administration expertise. Prior to joining F5, MacVittie was an award-winning technology editor at Network Computing Magazine where she evaluated and tested application-focused technologies including app security and encryption-related solutions. She holds a B.S. in Information and Computing Science from the University of Wisconsin at Green Bay, and an M.S. in Computer Science from Nova Southeastern University, and is an O'Reilly author.
CloudEXPO New York 2018, colocated with DevOpsSUMMIT and DXWorldEXPO New York 2018 will be held November 12-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI and Machine Learning to one location.
CloudEXPO | DevOpsSUMMIT | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.