27. Web server can refer to either the hardware (the
computer) or the software (the computer
application) that helps to deliver Web content
that can be accessed through the Internet.
The most common use of web servers is to host
websites, but there are other uses such as
gaming, data storage or running enterprise
applications.
Apache
* Only webserver to run on all major platforms
(*NIX, WINDOZ, MAC, FREEBSD and any other you
name it)
* Largest Market share holder for web servers
since 1996 and still growing.
36. A Copy of real data with faster (and/or
cheaper) access.
From Wikipedia : "A cache is a
collection of data duplicating original
stored elsewhere or computed earlier,
where the original data is expensive to
fetch(owing to longer access time) or
to compute, compared to the cost of
reading the cache."
37. MySQL query Cache : Cache in the DB
Disk : File Cache
In Memory : Memached
38. What is Memcache ?
Free & open source, highperformance, distributed
memory object caching system, generic in nature,
but intended for use in speeding up dynamic web
applications by alleviating database load.
Memcached is an inmemory keyvalue store for
small chunks of arbitrary data (strings, objects)
from results of database calls, API calls, or page
rendering.
Memcached is simple yet powerful. Its simple
design promotes quick deployment, ease of
development, and solves many problems facing large
data caches. Its API is available for most popular
languages.
65. Introduction
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and
traditional RDBMS systems (which provide rich queries and deep functionality).
MongoDB is document-oriented, schema-free, scalable, high-performance, open source. Written in C++
Mongo is not a relational database like MySQL
Goodbye rows and tables, hello documents and collections
Features
Document-oriented
Documents (objects) map nicely to programming language data types
Embedded documents and arrays reduce need for joins
No joins and no multi-document transactions for high performance and easy scalability
High performance
No joins and embedding makes reads and writes fast
Indexes including indexing of keys from embedded documents and arrays
High availability
Replicated servers with automatic master failover
Easy scalability
Automatic sharding (auto-partitioning of data across servers)
Reads and writes are distributed over shards
No joins or multi-document transactions make distributed queries easy and fast
Eventually-consistent reads can be distributed over replicated servers
66. Why ?
Cost - MongoDB is free
MongoDb is easily installable.
MongoDb supports various programming languages like C, C++, Java,Javascript, PHP.
MongoDB is blazingly fast
MongoDB is schemaless
Ease of scale-out
If load increases it can be distributed to other nodes across computer networks.
It's trivially easy to add more fields -- even complex fields -- to your objects.
So as requirements change, you can adapt code quickly.
Background Indexing
MongoDB is a stand-alone server
Development time is faster, too, since there are no schemas to manage.
It supports Server-side JavaScript execution.
Which allows a developer to use a single programming language for both client and server
side code
67. Limitations
Mongo is limited to a total data size of 2GB for all databases in 32-bit mode.
No referential integrity
Data size in MongoDB is typically higher.
At the moment Map/Reduce (e.g. to do aggregations/data analysis) is OK,
but not blisteringly fast.
Group By : less than 10,000 keys.
For larger grouping operations without limits, please use map/reduce .
Lack of predefined schema is a double-edged sword
No support for Joins & transactions
68. Mongo data model
A Mongo system (see deployment above) holds a set of databases
A database holds a set of collections
A collection holds a set of documents
A document is a set of fields
A field is a key-value pair
A key is a name (string)
A value is a
basic type like string, integer, float, timestamp, binary, etc.,
a document, or
an array of values
MySQL Term Mongo Term
database database
table collection
index index
75. Xdebug
Xdebug is a PHP extension that aims to
lend a helping hand in the process of
debugging your applications. Xdebug
offers features like:
* Automatic stack trace upon error
* Function call logging
* Display features such as enhanced
var_dump() output and code
coverage information
Open Source
Free
80. Apache Lucene is a free/open source
information retrieval software library,
originally created in Java by Doug
Cutting.
81. Scalable, HighPerformance Indexing
* small RAM requirements
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
Powerful, Accurate and Efficient Search Algorithms
* ranked searching best results returned first
* many powerful query types: phrase queries, wildcard
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
* daterange searching
* sorting by any field
* multipleindex searching with merged results
* allows simultaneous update and searching
CrossPlatform Solution
* Available as Open Source software under the Apache
License which lets you use Lucene in both commercial
and Open Source programs
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
82. Scalable, HighPerformance Indexing
* small RAM requirements
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
Powerful, Accurate and Efficient Search Algorithms
* ranked searching best results returned first
* many powerful query types: phrase queries, wildcard
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
* daterange searching
* sorting by any field
* multipleindex searching with merged results
* allows simultaneous update and searching
CrossPlatform Solution
* Available as Open Source software under the Apache
License which lets you use Lucene in both commercial
and Open Source programs
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
83. Scalable, HighPerformance Indexing
* small RAM requirements
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
Powerful, Accurate and Efficient Search Algorithms
* ranked searching best results returned first
* many powerful query types: phrase queries, wildcard
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
* daterange searching
* sorting by any field
* multipleindex searching with merged results
* allows simultaneous update and searching
CrossPlatform Solution
* Available as Open Source software under the Apache
License which lets you use Lucene in both commercial
and Open Source programs
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
84. Scalable, HighPerformance Indexing
* small RAM requirements
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
Powerful, Accurate and Efficient Search Algorithms
* ranked searching best results returned first
* many powerful query types: phrase queries, wildcard
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
* daterange searching
* sorting by any field
* multipleindex searching with merged results
* allows simultaneous update and searching
CrossPlatform Solution
* Available as Open Source software under the Apache
License which lets you use Lucene in both commercial
and Open Source programs
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
85. Scalable, HighPerformance Indexing
Pitfalls
* small RAM requirements
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
Powerful, Accurate and Efficient Search Algorithms
* Update = Delete + Add
* ranked searching best results returned first
* many powerful query types: phrase queries, wildcard
* No Partial document update
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
* daterange searching
* No Joins
* sorting by any field
* multipleindex searching with merged results
* allows simultaneous update and searching
CrossPlatform Solution
* Available as Open Source software under the Apache
License which lets you use Lucene in both commercial
and Open Source programs
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
86. Scalable, HighPerformance Indexing
* small RAM requirementsCode: FS Indexer
* incremental indexing as fast as batch indexing
* index size roughly 2030% the size of text indexed
private IndexWriter writer;
Powerful, Accurate and Efficient Search Algorithms
public Indexer(String indexDir) throws IOException {
Directory dir = FSDirectory.open(new File(indexDir));
* ranked searching best results returned first
writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.UNLIMITED);
* many powerful query types: phrase queries, wildcard
}
queries, proximity queries, range queries and more
* fielded searching (e.g., title, author, contents)
public void close() throws IOException {
* daterange searching
writer.close();
}
* sorting by any field
* multipleindex searching with merged results
public void index(String dataDir, FileFilter filter) throws Exception {
* allows simultaneous update and searching
File[] files = new File(dataDir).listFiles();
for (File f: files) {
Document doc = new Document();
CrossPlatform Solution
doc.add(new Field("contents", new FileReader(f)));
doc.add(new Field("filename", f.getName(),
* Available as Open Source software under the Apache
Field.Store.YES, Field.Index.NOT_ANALYZED));
License which lets you use Lucene in both commercial
writer.addDocument(doc);
}
and Open Source programs
}
* 100%pure Java
* Implementations in other programming languages
available that are indexcompatible
87. Code: Searcher
public void search(String indexDir, String q) throws IOException,
ParseException {
Directory dir = FSDirectory.open(new File(indexDir));
IndexSearcher is = new IndexSearcher(dir, true);
QueryParser parser = new QueryParser("contents",
new
StandardAnalyzer(Version.LUCENE_CURRENT));
Query query = parser.parse(q);
TopDocs hits = is.search(query, 10);
System.err.println("Found " + hits.totalHits + " document(s)");
for (int i=0; i<hits.scoreDocs.length; i++) {
ScoreDoc scoreDoc = hits.scoreDocs[i];
Document doc = is.doc(scoreDoc.doc);
System.out.println(doc.get("filename"));
}
is.close();
}