Www Search Engine But Not In Perl


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Www Search Engine But Not In Perl

  1. 1. Building a scalable distributed WWW search engine … NOT in Perl! Presented by Alex Chudnovsky (http://www.majectic12.co.uk) at Birmingham Perl Mongers User Group (http://birmingham.pm.org) V1.0 27/07/05
  2. 2. Contents <ul><li>History </li></ul><ul><li>Goals </li></ul><ul><li>Architecture </li></ul><ul><li>Implementation </li></ul><ul><li>Why not Perl? </li></ul><ul><li>Conclusions </li></ul><ul><li>Credits </li></ul><ul><li>Recommended reading </li></ul>
  3. 3. History (of my work in area of information retrieval) <ul><li>First primitive pathetic stone-age search engine: 1000 documents in the “index” (1997, Perl) </li></ul><ul><li>Second engine using proper inverted indexing for Jungle.com: 500,000 products indexed (Perl + Java, 2002) </li></ul><ul><li>Current: 50,000,000 pages indexed with a lot more to go (to be revealed, 2005) </li></ul>
  4. 4. Goals <ul><li>Build a distributed WWW search engine capable of dealing with at least 1 bln web pages based on principles of [email_address] and D.NET </li></ul><ul><li>See to it that the chosen language for implementation (more on this later) fits purpose or more likely learn how to make it work </li></ul><ul><li>Eventually make some money out of it </li></ul>
  5. 5. Architecture <ul><li>Data collection (crawling) </li></ul><ul><li>Indexing: turning text into numbers </li></ul><ul><li>Merging: turning indexed barrels into single searchable index </li></ul><ul><li>Searching: locating documents for given keywords </li></ul>
  6. 6. Data collection (crawling) Base Issues URLs to crawl and receives compressed pages Distributed c rawlers – receive lists of URLs to crawl, crawl them and send back compressed data. In the future will do distributed indexing Note: this stage is optional if you already have data to index, ie list of products with their descriptions
  7. 7. Crawler screenshot 1
  8. 8. Crawler screenshot 2
  9. 9. Crawler screenshot 3
  10. 10. Crawler screenshot 4
  11. 11. Crawler screenshot 5
  12. 12. Current Stats Source: http://www.majestic12.co.uk/projects/dsearch/stats.php as of 27/07/05
  13. 13. Indexing Indexing is a process of turning words into numbers and creating inverted index. Data barrel Doc #0: Birmingham Perl Mongers Doc #1: Birmingham City Doc #2: Perl City Lexicon (maps words to their numeric WordIDs) Birmingham – 0 Perl – 1 Mongers – 2 City – 3 Inverted Index (Each of the WordID has list of (ideally sorted) DocIDs) 0 -> 0, 1 1 -> 0, 2 2 -> 0, 3 -> 1, 2 Note: if you use database then it make sense to have clustered index on WordID
  14. 14. Merging Individual indexed barrels Single searchable index Note: this stage is not necessary if just one barrel is used as there will be no need to remap all Ids from local to their global equivalents.
  15. 15. Searching Searching is a process of finding documents that contain words from search query Doc #0: Birmingham Perl Mongers Doc #1: Birmingham City Doc #2: Perl City Lexicon (maps words to their numeric WordIDs) Birmingham – 0 Perl – 1 Mongers – 2 City – 3 Inverted Index (lists DocIDs for each of the WordID) 0 -> 0, 1 1 -> 0, 2 2 -> 0, 3 -> 1, 2 Note: if you use database then it make sense to cluster on WordID Search query: “Birmingham Perl” WordIDs: 0, 1 Intersection of DocIDs present in both lists (implementation of boolean AND logic): Not matched! 2 n/a Not matched! n/a 1 Matched! 0 0 Result 1 (Perl) 0 (Brum)
  16. 16. Search engine screenshot 1
  17. 17. Search engine screenshot 2
  18. 18. Implementation <ul><li>Microsoft .NET C# ported to Linux using Mono ( http://www.mono-project.com ) </li></ul><ul><li>~90k lines of code (minimal copy/paste) written from scratch </li></ul><ul><li>Low level of dependencies (SharpZipLib/SQLite/NPlot) </li></ul>
  19. 19. Why not Perl? (using C # instead) <ul><li>Not strong in GUI department </li></ul><ul><li>Hard to deal with Multi-Threading and Asyncronous sockets </li></ul><ul><li>OOP is more of a hack </li></ul><ul><li>Lax compile-time checks due to not being strictly typed </li></ul><ul><li>Fear of performance bottlenecks forcing to use C++ </li></ul><ul><li>Hard to profile for performance analysis </li></ul><ul><li>Managed memory lacks support for pointers (?) </li></ul><ul><li>Poor exceptions handling </li></ul><ul><li>I wanted something new :) </li></ul>
  20. 20. Conclusions <ul><li>Still work in progress, but some conclusions can be made already: </li></ul><ul><li>Inverted indexing approach helps to achieve fast searches </li></ul><ul><li>Its tough to build one – don’t try if you ain’t going to see it through! </li></ul><ul><li>Crawler is one tough piece of code – 6 months vs 2 months on searching </li></ul><ul><li>.NET C# is a decent language suitable for heavy duty tasks like this </li></ul>
  21. 21. Credits <ul><li>R&D: Alex Chudnovsky <alexc@majestic12.co.uk> </li></ul><ul><li>Pioneers*: FiddleAbout, dazza12, lazytom, Mordac, linuxbren, Cyber911, www.vanginkel.info , Vari, ASB, SEOBy.org, arni, japonicus, webstek.info | Pimpel, DimPrawn, Zyron, partys-bei-uns.de, jake, bull at webmasterworld, nada, dodgy4, sri-heinz </li></ul>* Volunteers running crawler and who crawled at least 1 mln URLs as of 27/07/05
  22. 22. Recommended reading <ul><li>“ The Anatomy of a Large-Scale Hypertextual Web Search Engine” Sergey Brin and Lawrence Page of Google ( http://www-db.stanford.edu/~backrub/google.html ) </li></ul><ul><li>“ Managing Gigabytes” Ian h. Witten et al ISBN 1-55860-570-3 </li></ul>
  23. 23. Join! Join the project (unmetered broadband required!): majestic12.co.uk Your name could be here!