Query for RAMDirectory for 6 GB Index File - apache-spark

I am writing a spark job, where use case if of millions of documents doing search on Lucene index for getting details.
The index is around 6 GB and contains around 40 million docs.Now I can't use elastic search as doing a batch search is getting bottlenecked. I used HDFS Directory for search and performance is bad.
I was thinking of creating g a RAMDirectory index searcher per executor.
I see following warning in the code :
Warning: This class is not intended to work with huge indexes. Everything beyond several hundred megabytes will waste resources (GC cycles), because it uses an internal buffer size of 1024 bytes, producing millions of byte[1024] arrays. This class is optimized for small memory-resident indexes. It also has bad concurrency on multithreaded environments.
My search is not simple(Use more like this and other term queries) which cannot be mimicked by spark SQL.
My question is has anybody used ram directory over Gb of file to see. My index will be read-only, so maybe I won't hit this issue.
If not how to solve this?

Related

Cassandra batch size

I have 6 Cassandra nodes mainly used for writing (95%).
What's the best approach to inserting data - individual inserts or batches? reason says batches are to be used, while keeping the "batch size" under 5kb to avoid node instability:
https://issues.apache.org/jira/browse/CASSANDRA-6487
Do these 5kb concern the size of the queries, as in number of chars * bytes_per_char? are there any performance drawbacks to fully running individual inserts?
Batch will increase performance if used for a single partition. You are able to get more through put of data inserted.

Sphinx getting slow after continuously adding and removing items

I have Sphinx search function with about 5m items. New items are added and removed continuously. Thereby Sphinx is getting slow after a while.
When i TRUNCATE RTINDEX the sphinx database and put every item back in sphinx again, than sphinx is fast again but after a while sphinx is getting slow again.
I don't want to truncate every day because it takes about an hour and a half to add the products to sphinx again.
Does someone know how to optimize sphinx to fix this problem? Maybe something with caching?
Some extra info:
Virtual memory 1021.73 MB used, 1021.99 MB total
Real memory 10.42 GB used, 31.39 GB total
Real-time indexes stores on disk in chunks. After a while there are many chunks, which impact performance. So, you need to optimize you index by executing OPTIMIZE INDEX command: http://sphinxsearch.com/docs/current.html#sphinxql-optimize-index

Elasticsearch bad indexing time

I am trying to migrate (copy) 35 million documents (which is a standard amount, not too big) between couchbase to elasticsearch.
My elasticsearch (version 1.3) cluster composed from 3 A3 (4 cores, 7 GB memory) CentOS Severs on Microsoft Azure (each server equals to a large server on Amazon)..
I used "timing data flow" indexing to store the docuemnts. each index represents a month and composed by 3 shards and 2 replicas.
when i start the migration script i see that the insertion time is becoming very slow (about 10 documents per second) and the load average of each server in the cluster jumping over than 1.5.
In addition, the JVM memory is being increased almost to 100% while the cpu shows 20% and the IOps shows 20 at max.
(i used Marvel CNC to get all these data)
Does anyone faced these kind of indexing problems in elasticsearch?
I would like to know if there are any parameters that i should be aware about to extend java memory?
is my cluster specifications good enough to handle 100 indexing per second.
is the indexing time depends on how big is the index? and should it be that slow?
Thnx Niv
I am quoting an answer I got in google group (link)
A couple of suggestions:
Disable replicas before large amounts of inserts (set replica count to 0), and only enable it afterwards again.
Use batching, actual batch size would depends on many factors (doc sizes, network, instances strengths)
Follow ES's advice on node setup, e.g. allocate 50% of the available memory size to the Java heap of ES, don't run anything else
on that machine, and disable swappiness.
Your index is already sharded, try spreading it out to 3 different servers instead of having them on one server ("virtual shards"). This
will help fan out the indexing load.
If you don't specify the document IDs yourself, make sure you use the latest ES, there's a significant improvement there in the ID
generation mechanism which could help speeding up things.
I applied points 1 & 3 and it seems that the problems solved :)
now i am indexing in rate of 80 docs per second and the load avg is low (0.7 at max)
I have to give the credit to Itamar Syn-Hershko that posted this reply.

solr: What is the memory limit for loading data to solr?

What is the memory limit for loading data into solr?
I tried loading a 1.1Gigabyte file and ended up with a 500 Server error.
Digging the log file showed me this:
ERROR - 2013-11-25 17:26:46.481; org.apache.solr.common.SolrException; null:java.lang.IllegalStateException: this writer hit an OutOfMemoryError; cannot commit
Solr runs on JVM, so the java heap space should be large enough to avoid OutOfMemoryException. There are obvious downside to increasing the Heap Space to a value too big, which is pointed out in the reference.
I would revisit the strategy of uploading large files, if I were you, and either do a batch processing by splitting the files or consider doing incremental updates (depending on your use case).

cassandra read performance for large number of keys

Here is situation
I am trying to fetch around 10k keys from CF.
Size of cluster : 10 nodes
Data on node : 250 GB
Heap allotted : 12 GB
Snitch used : property snitch with 2 racks in same Data center.
no. of sstables for cf per node : around 8 to 10
I am supercolumn approach.Each row contains around 300 supercolumn which in terms contain 5-10 columns.I am firing multiget with 10k row keys and 1 supercolumn.
When fire the call 1st time it take around 30 to 50 secs to return the result.After that cassandra serves the data from key cache.Then it return the result in 2-4 secs.
So cassandra read performance is hampering our project.I am using phpcassa.Is there any way I can tweak cassandra servers so that I can get result faster?
Is super column approach affects the read performance?
Use of super columns is best suited for use cases where the number of sub-columns is a relatively small number. Read more here:
http://www.datastax.com/docs/0.8/ddl/column_family
Just in case you haven't done this already, since you're using phpcassa library, make sure that you've compiled the Thrift library. Per the "INSTALLING" text file in the phpcassa library folder:
Using the C Extension
The C extension is crucial for phpcassa's performance.
You need to configure and make to be able to use the C extension.
cd thrift/ext/thrift_protocol
phpize
./configure
make
sudo make install
Add the following line to your php.ini file:
extension=thrift_protocol.so
After doing much of RND about this stuff we figured there is no way you can get this working optimally.
When cassandra is fetching these 10k rows 1st time it is going to take time and there is no way to optimize this.
1) However in practical, probability of people accessing same records are more.So we take maximum advantage of key cache.Default setting for key cache is 2 MB. So we can afford to increase it to 128 MB with no problems of memory.
After data loading run the expected queries to warm up the key cache.
2) JVM works optimally at 8-10 GB (Dont have numbers to prove it.Just observation).
3) Most important if you are using physical machines (not cloud OR virtual machine) then do check out the disk scheduler you are using.Set it NOOP which is good for cassandra as it reads all keys from one section reducing disk header movement.
Above changes helped to bring down time required for querying within acceptable limits.
Along with above changes if you have CFs which are small in size but frequently accessed enable row caching for it.
Hope above info is useful.

Resources