├── .DS_Store ├── .gitignore ├── .nojekyll ├── LICENSE ├── README.md ├── _sidebar.md ├── architectural-patterns └── index.md ├── basic-frontend-knowledge ├── css-basics.md ├── html-basics.md ├── images │ ├── foo-1.html.png │ ├── foo-2.html.png │ ├── foo-em.html.png │ ├── foo-no-p.html.png │ ├── html-basics-header.png │ └── simple-vs-more-meta.html.png └── javascript-basics.md ├── caching └── index.md ├── ci-cd └── index.md ├── containerization-virtualization └── index.md ├── databases ├── index.md ├── nosql-databases │ └── index.md └── relational-databases │ └── index.md ├── design-and-development-principles └── index.md ├── graph-databases └── index.md ├── graphql └── index.md ├── index.html ├── internet ├── .DS_Store ├── browsers-and-how-they-work.md ├── dns-and-how-it-works.md ├── how-does-the-internet-work.md ├── images │ ├── .DS_Store │ ├── bahtw_flow.png │ ├── bahtw_image008.jpg │ ├── bahtw_image009.png │ ├── bahtw_image011.png │ ├── bahtw_image013.png │ ├── bahtw_image015.png │ ├── bahtw_image017.png │ ├── bahtw_image019.png │ ├── bahtw_image022.gif │ ├── bahtw_image023.png │ ├── bahtw_image025.png │ ├── bahtw_image027.png │ ├── bahtw_image029.png │ ├── bahtw_image035.png │ ├── bahtw_image046.jpg │ ├── bahtw_image057.png │ ├── bahtw_image059.png │ ├── bahtw_image061.png │ ├── bahtw_image063.png │ ├── bahtw_image065.png │ ├── bahtw_image067.png │ ├── bahtw_image069.png │ ├── bahtw_image071.png │ ├── bahtw_layers.png │ ├── bahtw_reflow.png │ ├── bahtw_tree.png │ ├── bahtw_webkitflow.png │ ├── cgiarch.gif │ ├── dns1.png │ ├── dns2.png │ ├── dns3.png │ ├── dns4.png │ ├── dns5.png │ ├── ruswp_diag1.gif │ ├── ruswp_diag2.gif │ ├── ruswp_diag3.gif │ ├── ruswp_diag4.gif │ ├── ruswp_diag5.gif │ ├── ruswp_diag6.gif │ ├── ruswp_diag7.gif │ ├── ruswp_diag8.gif │ ├── ruswp_diag9.gif │ └── wiadn_structure.png ├── index.md ├── what-is-domain-name.md ├── what-is-hosting.md └── what-is-http.md ├── learn-a-programming-language └── index.md ├── learn-about-api-s └── index.md ├── message-brokers └── index.md ├── os-general-knowledge └── index.md ├── scaling └── index.md ├── search-engines └── index.md ├── testing └── index.md ├── version-control-systems └── index.md ├── web-security └── index.md ├── web-servers └── index.md └── websockets └── index.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | .history 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # TypeScript v1 declaration files 46 | typings/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | 76 | # parcel-bundler cache (https://parceljs.org/) 77 | .cache 78 | 79 | # Next.js build output 80 | .next 81 | 82 | # Nuxt.js build / generate output 83 | .nuxt 84 | dist 85 | 86 | # Gatsby files 87 | .cache/ 88 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 89 | # https://nextjs.org/blog/next-9-1#public-directory-support 90 | # public 91 | 92 | # vuepress build output 93 | .vuepress/dist 94 | 95 | # Serverless directories 96 | .serverless/ 97 | 98 | # FuseBox cache 99 | .fusebox/ 100 | 101 | # DynamoDB Local files 102 | .dynamodb/ 103 | 104 | # TernJS port file 105 | .tern-port 106 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/.nojekyll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Backend Developer Roadmap 2 | 3 | > Step by step guide to becoming a modern backend developer in 2023 4 | 5 | Live: https://muratdemirci.github.io/backend-dev-roadmap/#/ 6 | 7 | # Table of Contents 8 | 9 | 10 | 11 | - [Internet](./internet/index) 12 | * [**How Does the Internet Work?**](./internet/how-does-the-internet-work) 13 | * [**What is HTTP?**](./internet/what-is-http) 14 | * [**Browsers and how they work**](./internet/browsers-and-how-they-work) 15 | * [**DNS and how it works?**](./internet/dns-and-how-it-works) 16 | * [**What is Domain Name?**](./internet/what-is-domain-name) 17 | * [**What is hosting?**](./internet/what-is-hosting) 18 | 19 | 20 | + [Basic Frontend Knowledge](./basic-frontend-knowledge/index) 21 | * [**HTML**](./basic-frontend-knowledge/html-basic.md) 22 | * [**JavaScript**](./basic-frontend-knowledge/javascript-basics.md) 23 | * [**CSS**](./basic-frontend-knowledge/css-basics.md) 24 | 25 | - [Os and General Knowledge](./os-general-knowledge/index) 26 | * [**Terminal Usage**](./os-general-knowledge/terminal-usage.md) 27 | * [**How OSs work in General**](./os-general-knowledge/how-oss-work-in-general.md) 28 | * [**Process Management**](./os-general-knowledge/process-management.md) 29 | * [**Threads and Concurrency**](./os-general-knowledge/threads-and-concurrency.md) 30 | * [**Basic Terminal Commands**](./os-general-knowledge/basic-terminal-commands.md) 31 | * [**Memory Management**](./os-general-knowledge/memory-management.md) 32 | * [**Interprocess Communication**](./os-general-knowledge/interprocess-communication.md) 33 | * [**I/O Management**](./os-general-knowledge/i-o-management.md) 34 | * [**POSIX Basics**](./os-general-knowledge/posix-basics.md) 35 | * [**Basic Networking Concepts**](./os-general-knowledge/basic-networking-concepts.md) 36 | 37 | + [Learn a Programming Language](./learn-a-programming-language/index) 38 | * [**JavaScript**](./learn-a-programming-language/javascript.md) 39 | * [**PHP**](./learn-a-programming-language/php.md) 40 | * [**Golang**](./learn-a-programming-language/golang.md) 41 | 42 | - [Version Control Systems](./version-control-systems/index) 43 | * [**Basic Usage of Git**](./os-general-knowledge/basic-usage-of-git.md) 44 | 45 | + [Databases](./databases/index) 46 | * [Relational Databases](./databases/relational-databases/index) 47 | * [**PostgreSQL**](./databases/relational-databases/postgresql.md) 48 | * [**MySQL**](./databases/relational-databases/mysql.md) 49 | * [**MariaDB**](./databases/relational-databases/mariadb.md) 50 | * [**MS SQL**](./databases/relational-databases/mariadb.md) 51 | * [**Oracle**](./databases/relational-databases/oracle.md) 52 | * [NoSQL Databases](./databases/nosql-databases/index) 53 | * [**MongoDB**](./databases/relational-databases/oracle.md) 54 | * [**RethinkDB**](./databases/relational-databases/rethinkdb.md) 55 | * [**CouchDB**](./databases/relational-databases/couchdb.md) 56 | * [**DynamoDB**](./databases/relational-databases/dynamodb.md) 57 | * [ORMs](./databases/orms/index) 58 | * [ACID](./databases/acid/index) 59 | * [Transactions](./databases/transactions/index) 60 | * [N+1 Problem](./databases/n-plus-1-problem/index) 61 | * [Database Normalization](./databases/database-normalization/index) 62 | * [Indexes and how they work](./databases/indexes-and-how-they-works/index) 63 | * [Data Replication](./databases/data-replication/index) 64 | * [Sharding Strategies](./databases/sharding-strategies/index) 65 | * [CAP Theorem](./databases/cap-theorem/index) 66 | - [Learn about APIs](./learn-about-api-s/index) 67 | * [Authentication](./learn-about-api-s/authentication/index) 68 | * [**Cookie Based**](./learn-about-api-s/authentication/cookie-based.md) 69 | * [**OAuth**](./learn-about-api-s/authentication/oauth.md) 70 | * [**Basic Authentication**](./learn-about-api-s/authentication/basic-authentication.md) 71 | * [**Token Authentication**](./learn-about-api-s/authentication/token-authentication.md) 72 | * [**JWT**](./learn-about-api-s/authentication/jwt.md) 73 | * [**OpenID**](./learn-about-api-s/authentication/openid.md) 74 | * [**SAML**](./learn-about-api-s/authentication/saml.md) 75 | * [REST](./learn-about-api-s/rest/index) 76 | * [JSON APIs](./learn-about-api-s/json-apis/index) 77 | * [SOAP](./learn-about-api-s/soap/index) 78 | * [HATEOAS](./learn-about-api-s/hateoas/index) 79 | * [Open API Spec](./learn-about-api-s/soap/index) 80 | 81 | + [Caching](./caching/index) 82 | * [CDN](./caching/cdn.md) 83 | * [Client Side](./caching/client-side.md) 84 | * [Server Side](./caching/server-side.md) 85 | * [**Redis**](./caching/redis.md) 86 | * [**Memcached**](./caching/memcached.md) 87 | 88 | - [Web Security](./web-security/index) 89 | * [Hashing Algorithms](./web-security/hashing/index) 90 | * [**MD5**](./web-security/hashing/md5.md) 91 | * [**SHA Family**](./web-security/hashing/sha-family.md) 92 | * [**Bcrypt**](./web-security/hashing/bcrypt.md) 93 | * [**Scrypt**](./web-security/hashing/scrypt.md) 94 | * [HTTPS](./web-security/https/index) 95 | * [Content Security Policy](./web-security/content-security-policy/index) 96 | * [CORS](./web-security/cors/index) 97 | * [SSL/TLS](./web-security/ssl-tls/index) 98 | * [OWASP Security Risks](./web-security/owasp-security-risks/index) 99 | 100 | + [Testing](./testing/index) 101 | * [Unit Testing](./testing/unit-testing.md) 102 | * [Integration Testing](./testing/integration-testing.md) 103 | * [Functional Testing](./testing/functional-testing.md) 104 | 105 | - [CI / CD](./ci-cd/index) 106 | 107 | + [Design and Development Principles](./design-and-development-principles/index) 108 | * [SOLID](./design-and-development-principles/solid.md) 109 | * [KISS](./design-and-development-principles/kiss.md) 110 | * [YAGNI](./design-and-development-principles/yagni.md) 111 | * [DRY](./design-and-development-principles/dry.md) 112 | * [GOF Design Patterns](./design-and-development-principles/gof.md) 113 | * [Domain Driven Design](./design-and-development-principles/ddd.md) 114 | * [Test Driven Development](./design-and-development-principles/tdd.md) 115 | 116 | - [Architectural Patterns](./architectural-patterns/index) 117 | * [Monolothic Apps](./architectural-patterns/monolithic.md) 118 | * [Microservices](./architectural-patterns/microservices.md) 119 | * [SOA](./architectural-patterns/soa.md) 120 | * [CQRS and Event Sourcing](./architectural-patterns/cqrs-and-event-sourcing.md) 121 | * [Serverless](./architectural-patterns/serverless.md) 122 | 123 | + [Search Engines](./search-engines/index) 124 | * [Elastic Search](./search-engines/elastic-search.md) 125 | * [Solr](./search-engines/solr.md) 126 | 127 | - [Message Brokers](./message-brokers/index) 128 | * [RabbitMQ](./message-brokers/rabbitmq.md) 129 | * [Kafka](./message-brokers/kafka.md) 130 | 131 | + [Containerization vs Virtualization](./containerization-virtualization/index) 132 | * [Docker](./containerization-virtualization/docker.md) 133 | * [rkt](./containerization-virtualization/rkt.md) 134 | * [LXC](./containerization-virtualization/lxc.md) 135 | 136 | - [GraphQL](./graphql/index) 137 | * [Apollo](./graphql/apollo.md) 138 | * [Relay Modern](./graphql/relay-modern.md) 139 | 140 | + [Graph Databases](./graph-databases/index) 141 | * [Neo4j](./graph-databases/neo4j.md) 142 | 143 | - [WebSockets](./websockets/index) 144 | 145 | + [Web Servers](./web-servers/index) 146 | * [Nginx](./web-servers/nginx.md) 147 | * [Apache](./web-servers/apache.md) 148 | * [Caddy](./web-servers/caddy.md) 149 | * [MS IIS](./web-servers/ms-iis.md) 150 | 151 | - [Scaling](./scaling/index) 152 | * [Mitigation Strategies](./scaling/mitigation-strategies/index) 153 | * [**Graceful Degradation**](./scaling/mitigation-strategies/graceful-degradation.md) 154 | * [**Throttling**](./scaling/mitigation-strategies/throttling.md) 155 | * [**Backpressure**](./scaling/mitigation-strategies/backpressure.md) 156 | * [**Loadshifting**](./scaling/mitigation-strategies/loadshifting.md) 157 | * [**Circuit Breaker**](./scaling/mitigation-strategies/circuit-breaker.md) 158 | * [Understand the Diff](./scaling/understand-the-diff/index) 159 | * [**Instrumentation**](./scaling/understand-the-diff/instrumentation.md) 160 | * [**Monitoring**](./scaling/understand-the-diff/monitoring.md) 161 | * [**Telemetry**](./scaling/understand-the-diff/telemetry.md) 162 | * [Migration Strategies](./scaling/migration-strategies/index) 163 | * [Horizontal vs Vertical Scaling](./scaling/horizontal-vs-vertical-scaling/index) 164 | 165 | TOC credits: [https://roadmap.sh/backend](https://roadmap.sh/backend) -------------------------------------------------------------------------------- /_sidebar.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | - [Table of Contents](./) 4 | 5 | - [Internet](./internet/index) 6 | - [How Does the Internet Work?](./internet/how-does-the-internet-work) 7 | - [What is HTTP?](./internet/what-is-http) 8 | - [Browsers and how they work](./internet/browsers-and-how-they-work) 9 | - [Dns and How It Works?](./internet/dns-and-how-it-works) 10 | - [What is a Domain Name?](./internet/what-is-domain-name) 11 | - [What is a Hosting?](./internet/what-is-hosting) 12 | 13 | - [Basic Frontend Knowledge](./basic-frontend-knowledge/index) 14 | - [HTML Basics](./basic-frontend-knowledge/html-basics) 15 | - [JavaScript Basics](./basic-frontend-knowledge/javascript-basics) 16 | 17 | - [Os and General Knowledge](./os-general-knowledge/index) 18 | 19 | - [Learn a Programming Language](./learn-a-programming-language) 20 | 21 | - [Version Control Systems](./version-control-systems) 22 | 23 | - [Databases](./databases/index) 24 | - [Relational Databases](./databases/relational-databases/index) 25 | - [NoSQL Databases](./databases/nosql-databases/index) 26 | 27 | - [Learn about APIs](./learn-about-api-s/index) 28 | 29 | - [Caching](./caching/index) 30 | 31 | - [Web Security](./web-security/index) 32 | 33 | - [Testing](./testing/index) 34 | 35 | - [CI / CD](./ci-cd/index) 36 | 37 | - [Design and Development Principles](./design-and-development-principles/index) 38 | 39 | - [Architectural Patterns](./architectural-patterns/index) 40 | 41 | - [Search Engines](./search-engines/index) 42 | 43 | - [Message Brokers](./message-brokers/index) 44 | 45 | - [Containerization vs Virtualization](./containerization-virtualization/index) 46 | 47 | - [GraphQL](./graphql/index) 48 | 49 | - [Graph Databases](./graph-databases/index) 50 | 51 | - [WebSockets](./websockets/index) 52 | 53 | - [Web Servers](./web-servers/index) 54 | 55 | - [Scaling](./scaling/index) 56 | -------------------------------------------------------------------------------- /architectural-patterns/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/architectural-patterns/index.md -------------------------------------------------------------------------------- /basic-frontend-knowledge/css-basics.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/css-basics.md -------------------------------------------------------------------------------- /basic-frontend-knowledge/html-basics.md: -------------------------------------------------------------------------------- 1 | # Understanding HTML basics 2 | 3 | 4 | ![img](./images/html-basics-header.png) 5 | 6 | © [Understanding HTML basics](http://www.compciv.org/topics/web/html-basics/) all rights reserved. 7 | 8 | # Contents 9 | 1. [Understanding HTML basics](#understanding-html-basics) 10 | 2. [Contents](#contents) 11 | 3. [Introduction](#introduction) 12 | 4. [Bash and strings](#bash-and-strings) 13 | 5. [Seeing your own web pages](#seeing-your-own-web-pages) 14 | 6. [About HTML](#about-html) 15 | 1. [The HTML Element](#the-html-element) 16 | 2. [Let's make a webpage](#lets-make-a-webpage) 17 | 3. [Insignificant whitespace](#insignificant-whitespace) 18 | 4. [Tags as structure](#tags-as-structure) 19 | 5. [Nesting HTML elements](#nesting-html-elements) 20 | 6. [HTML attributes](#html-attributes) 21 | 7. [Unclosed tags](#unclosed-tags) 22 | 8. [Boilerplate HTML](#boilerplate-html) 23 | 24 | 25 | # Introduction 26 | 27 | How HTML works, and some of its terminology 28 | 29 | By now, we know how to scrape HTML for data. Now we're going to move in the opposite direction, turn data into HTML. Luckily, the logic for doing both, at least at a mass, automated scale, is largely the same. 30 | 31 | This guide covers some of the basics of HTML, assuming that you know literally nothing about it, and a few more techniques in dealing with multi-line strings in Bash. As web design and development are their own entire fields, this guide obviously can't cover everything, so consider this the bare minimum knowledge of HTML needed to make a functioning page. 32 | 33 | If you want to learn more beyond what I cover (and you _should_), I highly suggest starting with [Chapter 3 of Scott Murray's (free, online) book, Interactive Data Visualization for the Web](http://chimera.labs.oreilly.com/books/1230000000345/ch03.html), which covers the fundamentals and purposes of HTML, CSS, and JS. 34 | 35 | # Bash and strings 36 | 37 | For review, read the guides/sections to: 38 | 39 | * [Heredocs](/topics/bash/text-values#heredocs-info), which allow for writing longer, multi-line strings 40 | 41 | We know how to send a string of text to a new file: 42 | 43 | # To send a string to a new file, the old, clunky way: 44 | echo "

Hello there

" > some.html 45 | 46 | 47 | We use **heredocs** to make it easier to work with multi-line strings. So you'll want to be comfortable with this notation, using **cat**, to add a heredoc to a file (though we'll practice more of it in another lesson): 48 | 49 | # To send a string to a new file, using cat and heredocs 50 | cat > some.html <<'EOF' 51 | 52 | 53 |

Hello there

54 | Hey mom, I'm using "quotes"! 55 | EOF 56 | 57 | 58 | To _append_ to a file, you should already be familiar with `>>`: 59 | 60 | # To append a string using cat and heredocs 61 | cat >> some.html <<'EOF' 62 |

Here's another paragraph for you

63 | EOF 64 | 65 | 66 | # Seeing your own web pages 67 | 68 | If you're on **corn.stanford.edu**, think about working in your `~/WWW` directory, as all pages and files saved there can be accessible to the web. 69 | 70 | For example, in the code snippet below, I'm creating a page at: `~/WWW/playground/hello.html`: 71 | 72 | mkdir -p ~/WWW/playground 73 | cat > ~/WWW/playground/hello.html <<'EOF' 74 | 75 | 76 | This is Dan's page 77 | 78 | 79 | 80 |

Hello there

81 |

Just testing out HTML and using a Heredoc

82 |

Here's a 83 | kitten: 84 |

85 | 86 | EOF 87 | 88 | # And let's add a little more, notice the use of double 89 | # right-braces to append to the file 90 | 91 | cat >> ~/WWW/playground/hello.html <<'EOF' 92 |

And here's Bill Murray

93 | 94 | EOF 95 | 96 | 97 | My **SUnet ID** is `dun`, which means `~/WWW/playground/hello.html` will be viewable at: 98 | 99 | [http://stanford.edu/~dun/playground/hello.html](http://stanford.edu/~dun/playground/hello.html) 100 | 101 | About HTML 102 | ---------- 103 | 104 | ### The HTML Element 105 | 106 | The structural building block of HTML is the [HTML Element](http://en.wikipedia.org/wiki/HTML_element) 107 | 108 | Below is an example of a **paragraph** element: 109 | 110 |

111 | "They’ll keep out of my way," she insisted. "It takes two to make an accident." 112 |

113 | 114 | 115 | The textual content in the paragraph element is enclosed a **start tag**, `

`, and its corresponding **end tag**, `

` – note the end tag's _forward-slash_ that makes the difference between it and the start tag. 116 | 117 | ### Let's make a webpage 118 | 119 | And that's about all we need to know to make a _functional_ (though egregiously non-standard) web page. If you're on **corn.stanford.edu**, change into your personal (but not _private_) `~/WWW` directory and create a subdirectory for trying things out: 120 | 121 | mkdir -p ~/WWW/webtest 122 | cd ~/WWW/webtest 123 | # Make a webpage named `foo.html` consisting of a single paragraph element: 124 | cat > foo.html <<'EOF' 125 |

126 | "They'll keep out of my way," she insisted. "It takes two to make an accident." 127 |

128 | EOF 129 | 130 | 131 | **Note:** Above, [I use what's called a "heredoc"](http://stackoverflow.com/questions/2953081/how-can-i-write-a-here-doc-to-a-file-in-bash-script) to quickly dump a line into a new file. If you find its syntax weird, then just use **nano** to create the new file. 132 | 133 | If you visit http://www.stanford.edu/~your\_sunet\_id/webtest/foo.html, you should see something like this: 134 | 135 | ![img](./images/foo-1.html.png) 136 | 137 | That's not very impressive, so add a couple of other paragraph elements (and some arbitrary whitespace). Again, use **nano** to copy-and-paste if you don't like the look of that `EOF`: 138 | 139 | cat >> foo.html <<'EOF' 140 |

141 | "Suppose you met somebody just as careless as yourself." 142 | 143 |

144 |

145 | "I hope I never will," she answered. "I hate careless people. That's why I like you." 146 |

147 | EOF 148 | 149 | 150 | The result: 151 | 152 | ![img](./images/foo-2.html.png) 153 | 154 | ### Insignificant whitespace 155 | 156 | One thing that should be apparent is that the _amount of whitespace_, both between the elements and within the tags of the elements, makes not a bit of difference in the _physical_ layout of the webpage, as rendered by the browser. 157 | 158 | Let's confirm that, via the command-line. Execute a command that removes **newline** characters from `foo.html` and redirect it into a new file: `foo-oneline.html` 159 | 160 | cat foo.html | tr -d '\n' > foo-oneline.html 161 | 162 | 163 | Visit the `foo-oneline.html` in your browser. You should see no change to the physical appearance of the text. 164 | 165 | HTML is said to be a **whitespace insignificant** language. In terms of the _content_, whitespace doesn't make a difference – all consecutive spaces and newlines are treated as a single space. This is mostly trivia to us, but in pragmatic terms, this means we can space HTML elements as much (or as little) as we need to, without disrupting what is shown in the browser. 166 | 167 | ### Tags as structure 168 | 169 | Now instead of removing whitespace, let's remove the **tags** of the elements, and save the result as a new file, `foo-no-p.html`. We can do this in two ways; using the **pup** HTML parser: 170 | 171 | cat foo.html | pup 'text{}' > foo-no-p.html 172 | 173 | 174 | – or via good 'ol **sed** and its **substitution** function: 175 | 176 | cat foo.html | sed -E 's###g' > foo-no-p.html 177 | 178 | 179 | Now visit `foo-no-p.html`: 180 | 181 | ![img](./images//foo-no-p.html.png) 182 | 183 | Looks like the `

` tags made all the difference. By default, web browsers treat `

` elements as _blocks_ – each block element occupies an entire "line" of the browser window. With the `

` tags removed, no such blocks exist, and thus, no line-by-line separation. 184 | 185 | **Note:** The block nature of the paragraph (i.e. `

`) element is the default, but ultimately, that characteristic, as well as the _physical appearance_ of paragraphs, and _every other element of a webpage_, is completely mutable, as we'll see when we get to the topic of [Cascading Style Sheets](#css) 186 | 187 | ### Nesting HTML elements 188 | 189 | One characteristic of HTML is the ability to nest elements within each other. For example, if we wanted to _emphasize_ a sentence in a paragraph, we would wrap that sentence in `` tags: 190 | 191 | cat foo.html | sed -E 's#(I hate careless people)#\1#' 192 | 193 | 194 | (Note the usage of [capturing groups](http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/): one of the best features of regular expressions) 195 | 196 | The result: 197 | 198 |

199 | "They'll keep out of my way," she insisted. "It takes two to make an accident." 200 |

201 |

202 | "Suppose you met somebody just as careless as yourself." 203 | 204 |

205 | 206 | 207 |

208 | "I hope I never will," she answered. "I hate careless people. That's why I like you." 209 |

210 | 211 | 212 | And the result, if we pipe it into a new page named `foo-em.html` – notice the italicized text: 213 | 214 | ![img](./images/foo-1.html.png) 215 | 216 | There's not much to note here, except that you want your nested start and end tags to be self-contained within their **parent\_\_element. The `

` element is considered to be the \_\_parent** of the `` element: 217 | 218 |

219 | "I hope I never will," she answered. "I hate careless people. That's why I like you." 220 |

221 | 222 | 223 | This is **bad** form, having the child element's closing tag _after_ its parent's closing tag: 224 | 225 |

226 | "I hope I never will," she answered. "I hate careless people. That's why I like you." 227 |

228 | 229 | 230 | 231 | – but _visually_, most browsers can deal with such mistakes. However, for the purposes of keeping your sanity, you don't want to be sloppy here. As we've seen before, the tagged elements essentially define the structure of the document. 232 | 233 | ### HTML attributes 234 | 235 | One more bit of syntax and we'll have covered just about all we need to know about HTML. The code for an **anchor-tag**, commonly referred to as a **hyperlink**, looks like this: 236 | 237 | Click here please 238 | 239 | 240 | The `` tag encloses the text element, `Click here please`, and has an **attribute** with the name of `href`. The **value** of that `href` attribute is `"http://www.example.com"`, which is the destination URL. 241 | 242 | To summarize the components of the above hyperlink element: 243 | 244 | The tag 245 | 246 | `` 247 | 248 | The attribute 249 | 250 | `href` 251 | 252 | The attribute's value 253 | 254 | `"http://www.example.com"` 255 | 256 | The text 257 | 258 | Click here please 259 | 260 | The proper syntax for attributes is that they are inside the _start tag_, and a tag can have more than one attribute. The following variation will cause the browser to pop-open a new window for the clicked link: 261 | 262 | Click here please 263 | 264 | 265 | ### Unclosed tags 266 | 267 | Some tags do not need a corresponding **end** tag. One example is the `` tag, which is used to display an image that exists at the URL pointed to by its `src` attribute: 268 | 269 | 270 | 271 | 272 | On a conceptual level, this makes some sense: an _image_ is a standalone element, it shouldn't enclose a text element, nor any other kind of element. Same thing with the `
` tag, which denotes a **line-break**. Which tags _don't_ need to be closed? It's a matter of memorization, but it happens to only be a few (fnd if you do include an unnecessary closing tag, it won't break the page). 273 | 274 | ### Boilerplate HTML 275 | 276 | Believe it or not, but we now know the essentials for to constructing a usable HTML web page. The rest is memorization of certain conventions and for the kinds of tags and their corresponding attributes (as we'll see in the lesson CSS, the name of tag and its appearance, as rendered by the browser, have nothing to do with each other). 277 | 278 | Why we're able to get away with memorizing so little is that Web browsers have learned to cope with poor HTML, which is why our paragraph-only **foo.html** page shows up just fine. There is a [minimal amount of boilerplate to make it a valid HTML5 document](http://stackoverflow.com/questions/9797046/whats-a-valid-html5-document)…And again, this is mostly irrelevant since the browser will compensate for our laziness, at least on basic pages. 279 | 280 | However, when we start working with stylesheets and JavaScript, we will want to be more formal in our boilerplate. Here's an example of a page with a `` tag (which doesn't need to be closed) and a meta `` tag: 281 | 282 | <!doctype html> 283 | <title>My page 284 |

A headline

285 |

286 | This is a paragraph of text. 287 |

288 |

289 | Here's a link to the NYT 290 |

291 | 292 | 293 | Here's some more boilerplate, the `` element is used to enclose meta information and links to external files and code, which we'll cover later, and the `` tag wraps around all the actual content of the page: 294 | 295 | 296 | 297 | My page 298 | 299 | 300 |

A headline

301 |

302 | This is a paragraph of text. 303 |

304 |

305 | Here's a link to the NYT 306 |

307 | 308 | 309 | 310 | Try outputting these two files to your "~/WWW" directory, one with some boilerplate and the other with more boilerplate, and then visiting them in your browser: 311 | 312 | This page will live at `www.stanford.edu/~yourname/test/simple.html` 313 | 314 | mkdir -p ~/WWW/test/ 315 | cat > ~/WWW/test/simple.html <<'EOF' 316 | 317 | My page 318 |

A headline

319 |

320 | This is a paragraph of text. 321 |

322 |

323 | Here's a link to the NYT 324 |

325 | EOF 326 | 327 | 328 | This other page will live at `www.stanford.edu/~yourname/test/more.html` 329 | 330 | mkdir -p ~/WWW/test/ 331 | cat > ~/WWW/test/more.html <<'EOF' 332 | 333 | 334 | My page 335 | 336 | 337 |

A headline

338 |

339 | This is a paragraph of text. 340 |

341 |

342 | Here's a link to the NYT 343 |

344 | 345 | EOF 346 | 347 | 348 | Visit those two pages you created. Notice any difference (at least in a modern browser)? There likely won't be, and when it comes to metadata, such as the **attributes** of HTML, it shouldn't be visible on the page anyway. 349 | 350 | ![img](./images/simple-vs-more-meta.html.png) 351 | 352 | Source: 353 | 354 | http://www.compciv.org/topics/web/html-basics/ -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/foo-1.html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/foo-1.html.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/foo-2.html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/foo-2.html.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/foo-em.html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/foo-em.html.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/foo-no-p.html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/foo-no-p.html.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/html-basics-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/html-basics-header.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/images/simple-vs-more-meta.html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/basic-frontend-knowledge/images/simple-vs-more-meta.html.png -------------------------------------------------------------------------------- /basic-frontend-knowledge/javascript-basics.md: -------------------------------------------------------------------------------- 1 | # Understanding JavaScript basics 2 | 3 | © [Beginner’s Guide to JavaScript](https://codeberryschool.com/blog/en/beginners-guide-to-javascript) all rights reserved. 4 | 5 | >This document is at the introductory level. If you want to access more information about javascript, you can access it from [this](https://javascript.info) link. 6 | 7 | # Contents 8 | 1. [Understanding JavaScript basics](#understanding-javascript-basics) 9 | 2. [Contents](#contents) 10 | 3. [Introduction](#introduction) 11 | 4. [Variables](#variables) 12 | 5. [If Statements](#if-statements) 13 | 6. [Loops](#loops) 14 | 1. [The For Loop](#the-for-loop) 15 | 2. [The While Loop](#the-while-loop) 16 | 7. [Functions](#functions) 17 | 8. [Conclusion](#conclusion) 18 | 19 | 20 | # Introduction 21 | JavaScript is the language of the web. Almost every site you visit in your web browser will be using it in some manner to enhance the user experience. This is why JavaScript is such a desirable component of the modern programmer’s toolkit. There really is no substitute for this flexible language if you want to create brilliant browser-based experiences capable of hooking in customers, clients, and prospective employers. 22 | 23 | Want to create a website for your fast-growing socks-for-dogs business? Or how about an in-browser VR experience of what it’s like to visit your mother-in-law’s house at Christmas? You’ll have to learn JavaScript if you want to achieve these noble dreams and so much more. 24 | 25 | So if any of that takes your fancy (or you’re just bored on the toilet at work), read on to find out more about the basics of JavaScript and begin your journey towards becoming a web-programming ninja. 26 | 27 | # Variables 28 | A great place to start is with variables. Variables are where coders store information that a program needs whilst it is running. They’re like boxes that you can put **stuff** in. A programmer can create a variable in code, fill it with something, and then access it later. This way information can be available when it is needed. 29 | 30 | ___So, how do I create a variable in code?___ 31 | 32 | Like this: 33 | ```javascript 34 | var myCoolVariable; 35 | ``` 36 | 37 | ___What the hell does that mean?___ 38 | 39 | Glad you asked. The line above consists of two parts that come together to create a variable. Let’s break it down. 40 | 41 | - var 42 | - In JavaScript, this is a reserved word. There’s quite a few of these in the language and they all have dedicated jobs. This one tells the program you’re about to create a variable. 43 | - myCoolVariable 44 | - This is the variable identifier, which is just its name. This could be anything, from ‘cat’ to ‘antidisestablishmentarianism’ (please don’t name your variables this). The variable identifier is used to reference the variable later when you need it. It is considered good practice to give your variables names that describe what they do. So if you have a variable to contain your age, then you should probably call it myAge. Do this consistently, and your fellow programmers will love you and buy you things. 45 | 46 | ___Okay, cool, but what next?___ 47 | 48 | Remember when I said variables are like boxes? Well, the code above creates the box, but we haven’t yet put anything inside it. This is the next step. But before that, a word on data types. 49 | 50 | ___Data who?___ 51 | 52 | Data types are the different kinds of variables you can create. Mostly all programming languages have these. Some are very strict about them. They make you state exactly what type of variable you’re creating from the get-go and then stick to that throughout. JavaScript isn’t like this. You can create a variable of a certain type in JavaScript and then change it later on a whim as variable values and types can be changed at any time. Woohoo. Go crazy. 53 | 54 | Here are some of the data types available to JavaScript programmers. 55 | 56 | - Number 57 | - The Number type defines a variable with a numeric value. This type of variable can theoretically store values from -Infinity to +Infinity. It can also store a special value, NaN, which means ‘Not a Number’ and happens when you’ve done something wrong and confused JavaScript. Poor JavaScript. 58 | - String 59 | - The String type defines a variable that contains text, like ‘Hello’, ‘Goodbye’ or ‘Backstreet’s Back, Alright!’ 60 | - Boolean 61 | - The Boolean type defines a variable that can be either true or false. This type of variable is often used for making decisions in code. Should I stay or should I go? Booleans have the answer. 62 | 63 | There are other data types available and if you want to look into them, you can click [here](https://www.w3schools.com/js/js_datatypes.asp). 64 | 65 | 66 | **Giving Variables a Value** 67 | 68 | Let’s look at how to put stuff into variables. The following is some code that does just that. 69 | 70 | ```javascript 71 | myCoolVariable = 10; 72 | myCoolVariable = ‘hello’; 73 | myCoolVariable = true; 74 | ``` 75 | The image above shows some code that sets myCoolVariable three times: once to a Numeric value (10), to a String value (‘hello’) and then to a Boolean value (true). 76 | 77 | ___Creating and Setting a Variable at the Same Time___ 78 | 79 | It’s also possible to create and set a variable all at once. You do it like this: 80 | 81 | ```javascript 82 | var myCoolVariable = 10; 83 | ``` 84 | Here we create myCoolVariable and give it the value 10 in one line. Check us out. Wonderful. 85 | 86 | ___Referencing a Variable Later___ 87 | 88 | Creating and setting variables is great. But the true power comes later when you actually use them. So what does that look like? It’s easy. Just use the identifier. 89 | ```javascript 90 | var myCoolVariable = 10; 91 | var myCoolVariableDouble = myCoolVariable + myCoolVariable; 92 | ``` 93 | 94 | Here we create myCoolVariable and give it the value 10. Then we create another variable, myCoolVariableDouble and set it to the result of adding myCoolVariable to itself. So now myCoolVariableDouble equals 20 and we have two variables in the program. Two! Get the camera, dad. 95 | 96 | ___Enough about Variables___ 97 | 98 | We’ve covered the basics of variables: creating them, setting them and referencing them. But there is so much more to programming in JavaScript than that. Now that we have this down, we can move on to bigger and better things. Like if statements. 99 | 100 | # If Statements 101 | 102 | So we’ve got variables down, but how do we use them to do cool and awesome things? Well, one of the ways is by using if statements. 103 | 104 | An ‘if statement’ is a way in which a programmer can build decision-based logic into their code. This means that we can tell our programs to do something based on a certain condition. Let’s look at an example. 105 | ```javascript 106 | If (10 > 20) { 107 | // Run this code 108 | } else { 109 | // Run this code 110 | } 111 | ``` 112 | 113 | > {}’s define a code block. Some JavaScript tools, like the if statement, require these in order to separate different bits of code. 114 | 115 | Let’s break this down. 116 | 117 | - if 118 | - This is another reserved word. It indicates to the program that the following code will be an if statement. 119 | - (10 > 20) 120 | - This part is the condition. The program will evaluate this and then choose what to do based on the result. A condition always outputs a Boolean value, i.e. true or false. If the output of the condition is true, the if statement will run the code block immediately after the closing bracket of the condition. If it evaluates to false, then the code in the else block will be run instead, which is exactly what happens here since 10 is not more than 20. 121 | - else 122 | - This is another JavaScript keyword. It simply defines the code that should run if the condition evaluates to false. The else block is not required. If you add it, then you’re technically creating an if else statement. 123 | 124 | Hopefully, it is now clear why we need to use {} here. Without defining a code block, it wouldn’t be clear to the program which code should run if the condition evaluates to true or if it evaluates to false. 125 | 126 | If statements are one of the core building blocks of complex programs. Mastering these is imperative to becoming a competent JavaScript programmer. 127 | 128 | # Loops 129 | 130 | Loops are another important tool. As the name suggests, these run bits of code over and over again until a condition is met. There are a few different kinds of loops, but we’re only going to look at two here. I’ll provide links to further study. 131 | 132 | ## The For Loop 133 | 134 | We will look at the for loop first. Here’s an example. 135 | ```javascript 136 | var numberOfIterations = 10; 137 | for (var i = 0; i < numberOfIterations; i++) { 138 | // do something 10 times 139 | } 140 | ``` 141 | 142 | This might look a little weird compared to other stuff, but it becomes really straightforward when you break it down. I’ll go over each individual part. 143 | 144 | - var numberOfIterations = 10 145 | - This is just the code for creating and setting a variable in one go. 146 | - for (var i = 0; i < numberOfIterations; i++) 147 | - for 148 | - Another reserved word. This tells the program you’re about to write a for loop. 149 | - var i = 0 150 | - Creating and setting a variable again. This is a special case because we’re creating it within the for loop. This means that variable i will only exist for the duration of that for loop. Once it’s done executing, i will be discarded. Forever. Goodbye i. 151 | - i < numberOfIterations 152 | - This line tells the for loop to execute only while the variable i is less than the value of numberOfIterations (10). 153 | - i++ 154 | - Finally, this line tells the for loop that once it is done executing a single iteration, it should increase the value of i by 1. 155 | 156 | 157 | I hope it’s now quite easy to see how the for loop works. It creates a temporary variable to track the number of loops it has done: (i), then it defines the condition for execution (only while i < some value) and then it defines how i should increase with each loop (in this case, +1 but it can really be anything you want). 158 | 159 | Evidently, the for loop is good when you know how many times you want to run something. But what about when you don’t? Here comes the while loop. 160 | 161 | ## The While Loop 162 | 163 | The while loop is simpler than the for loop. It just takes a condition and executes until that condition is false. Here’s an example. 164 | 165 | ```javascript 166 | var shouldKeepRunning = true; 167 | while (shouldKeepRunning) { 168 | // Do some code 169 | shouldKeepRunning = false; 170 | } 171 | ``` 172 | 173 | - while 174 | - We’re telling the program we’re about to write a while loop. 175 | - (shouldKeepRunning) 176 | - This is the condition. The loop will run while the value of shouldKeepRunning is true. This is the same as writing shouldKeepRunning == true, but we can write it like this as shorthand. 177 | 178 | > JavaScript uses == to compare two values, as = is used to set a value. So if you write if (10 == 20), you’re really saying ‘if 10 is equal to 20’. 179 | 180 | This loop will only run once as we immediately set shouldKeepRunning to false on the first iteration. It will probably be a little different in your code, but it’s important to make sure that the loop will stop at some point. We don’t want to cause a global catastrophe. 181 | 182 | These are the only two loops we will go over here, but if you want to learn more, you can check out [this link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration). 183 | 184 | # Functions 185 | 186 | All the tools we’ve got right now are great for writing small, sequential scripts, but what if we want to write larger programs that make use of the same bits of code over and over? We don’t want to have to constantly copy and paste any code we want to reuse. This is where functions come in. 187 | 188 | Functions are reusable chunks of code. Here’s an example. 189 | 190 | ```javascript 191 | function doSomething(argumentOne, argumentTwo) { 192 | // do something here 193 | } 194 | ``` 195 | Breaking this down, we get: 196 | 197 | - function 198 | - Just another JavaScript keyword. 199 | - doSomething 200 | - This is the function identifier. Just like a variable identifier, it lets us refer to this function later in code. 201 | - (argumentOne, argumentTwo) 202 | - The code within the brackets is the argument list. The two values argumentOne and argumentTwo behave as variables within the function and therefore can be used as such. We’ll see in a second how these variables get set. 203 | 204 | Any code defined within the function block can be run as many times as you like simply by invoking the function. Here’s an example of that. 205 | 206 | ```javascript 207 | doSomething(10, 20); 208 | ``` 209 | 210 | We use the function identifier doSomething and then we pass two arguments, 10 and 20. These arguments that we pass will then populate the arguments in the function’s argument list, argumentOne and argumentTwo. Order matters, so argumentOne will get the value 10, and argumentTwo will get the value 20. 211 | 212 | Functions operate the same as variables in that you can only refer to a function within the block, and all child blocks, where it was defined. If you have a function that was created inside an if statement block, for example, then you can’t use it outside of that block. 213 | 214 | Functions are extremely important tools if you want to create complex and dynamic programs, so they’re important to practice. For more information, [see here](https://www.w3schools.com/js/js_functions.asp). 215 | 216 | # Conclusion 217 | 218 | I’ve gone over some of the basics of JavaScript programming in this article, but there is a lot more to know. Coding is a practical skill, and as such can only be learned properly with practice. There are plenty of services out there to help you do this, like CodeAcademy, CodeSchool, Pluralsight and, of course, Codeberry! I hope this information will be useful to you as a handy reference guide for the future. Good luck with your coding career! -------------------------------------------------------------------------------- /caching/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/caching/index.md -------------------------------------------------------------------------------- /ci-cd/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/ci-cd/index.md -------------------------------------------------------------------------------- /containerization-virtualization/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/containerization-virtualization/index.md -------------------------------------------------------------------------------- /databases/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/databases/index.md -------------------------------------------------------------------------------- /databases/nosql-databases/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/databases/nosql-databases/index.md -------------------------------------------------------------------------------- /databases/relational-databases/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/databases/relational-databases/index.md -------------------------------------------------------------------------------- /design-and-development-principles/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/design-and-development-principles/index.md -------------------------------------------------------------------------------- /graph-databases/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/graph-databases/index.md -------------------------------------------------------------------------------- /graphql/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/graphql/index.md -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | Learn to become a modern backend developer 14 | 15 | 16 |
17 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /internet/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/.DS_Store -------------------------------------------------------------------------------- /internet/browsers-and-how-they-work.md: -------------------------------------------------------------------------------- 1 | # Browsers and How They Work? 2 | 3 | By [Tali Garsiel](https://www.html5rocks.com/profiles/#taligarsiel) and [Paul Irish](https://www.html5rocks.com/profiles/#paulirish) 4 | 5 | Published: August 5th, 2011 6 | 7 | ## Introduction 8 | 9 | Web browsers are the most widely used software. In this primer, I will explain how they work behind the scenes. We will see what happens when you type `google.com` in the address bar until you see the Google page on the browser screen. 10 | 11 | ### Table of Contents 12 | 13 | 1. [Introduction](#Introduction) 14 | 1. [The browsers we will talk about](#The-browsers-we-will-talk-about) 15 | 2. [The browser's main functionality](#The-browser-main-functionality) 16 | 3. [The browser's high level structure](#The-browser-high-level-structure) 17 | 2. [The rendering engine](#The-rendering-engine) 18 | 1. [Rendering engines](#Rendering-engines) 19 | 2. [The main flow](#The-main-flow) 20 | 3. [Main flow examples](#Main-flow-examples) 21 | 3. [Parsing and DOM tree construction](#Parsing-general) 22 | 1. [Parsing: general](#Parsing-general) 23 | 1. [Grammars](#Grammars) 24 | 2. [Parser--Lexer combination](#Parser-Lexer-combination) 25 | 3. [Translation](#Translation) 26 | 4. [Parsing example](#Parsing-example) 27 | 5. [Formal definitions for vocabulary and syntax](#Formal-definitions-for-vocabulary-and-syntax) 28 | 6. [Types of parsers](#Types-of-parsers) 29 | 7. [Generating parsers automatically](#Generating-parsers-automatically) 30 | 2. [HTML Parser](#HTML-Parser) 31 | 1. [The HTML grammar definition](#The-HTML-grammar-definition) 32 | 2. [Not a context free grammar](#Not-a-context-free-grammar) 33 | 3. [HTML DTD](#HTML-DTD) 34 | 4. [DOM](#DOM) 35 | 5. [The parsing algorithm](#The-parsing-algorithm) 36 | 6. [The tokenization algorithm](#The-tokenization-algorithm) 37 | 7. [Tree construction algorithm](#Tree-construction-algorithm) 38 | 8. [Actions when parsing is finished](#Actions-when-the-parsing-is-finished) 39 | 9. [Browser error tolerance](#Browsers-error-tolerance) 40 | 3. [CSS parsing](#CSS-parsing) 41 | 1. [WebKit CSS parser](#WebKit-CSS-parser) 42 | 4. [The order of processing scripts and style sheets](#The-order-of-processing-scripts-and-style-sheets) 43 | 1. [Scripts](#Scripts) 44 | 2. [Speculative parsing](#Speculative-parsing) 45 | 3. [Style sheets](#Style-sheets) 46 | 4. [Render tree construction](#Render-tree-construction) 47 | 1. [The render tree relation to the DOM tree](#The-render-tree-relation-to-the-DOM-tree) 48 | 2. [The flow of constructing the tree](#The-flow-of-constructing-the-tree) 49 | 3. [Style Computation](#Style-Computation) 50 | 1. [Sharing style data](#Sharing-style-data) 51 | 2. [Firefox rule tree](#Firefox-rule-tree) 52 | 1. [Division into structs](#Division-into-structs) 53 | 2. [Computing the style contexts using the rule tree](#Computing-the-style-contexts-using-the-rule-tree) 54 | 3. [Manipulating the rules for an easy match](#Manipulating-the-rules-for-an-easy-match) 55 | 4. [Applying the rules in the correct cascade order](#Applying-the-rules-in-the-correct-cascade-order) 56 | 1. [Style sheet cascade order](#Style-sheet-cascade-order) 57 | 2. [Specificity](#Specificity) 58 | 3. [Sorting the rules](#Sorting-the-rules) 59 | 4. [Gradual process](#Gradual-process) 60 | 5. [Layout](#Layout) 61 | 1. [Dirty bit system](#Dirty-bit-system) 62 | 2. [Global and incremental layout](#Global-and-incremental-layout) 63 | 3. [Asynchronous and synchronous layout](#Asynchronous-and-Synchronous-layout) 64 | 4. [Optimizations](#Optimizations) 65 | 5. [The layout process](#The-layout-process) 66 | 6. [Width calculation](#Width-calculation) 67 | 7. [Line breaking](#Line-Breaking) 68 | 6. [Painting](#Painting) 69 | 1. [Global and incremental](#Global-and-Incremental) 70 | 2. [The painting order](#The-painting-order) 71 | 3. [Firefox display list](#Firefox-display-list) 72 | 4. [WebKit rectangle storage](#WebKit-rectangle-storage) 73 | 7. [Dynamic changes](#Dynamic-changes) 74 | 8. [The rendering engine's threads](#The-rendering-engines-threads) 75 | 1. [Event loop](#Event-loop) 76 | 9. [CSS2 visual model](#css) 77 | 1. [The canvas](#The-canvas) 78 | 2. [CSS box model](#CSS-Box-model) 79 | 3. [Positioning scheme](#Positioning-scheme) 80 | 4. [Box types](#Box-types) 81 | 5. [Positioning](#Positioning) 82 | 1. [Relative](#Relative) 83 | 2. [Floats](#Floats) 84 | 3. [Absolute and fixed](#Absolute-and-fixed) 85 | 6. [Layered representation](#Layered-representation) 86 | 10. [Resources](#Resources) 87 | 88 | ## The browsers we will talk about 89 | 90 | There are five major browsers used on desktop today: Chrome, Internet Explorer, Firefox, Safari and Opera. On mobile, the main browsers are Android Browser, iPhone, Opera Mini and Opera Mobile, UC Browser, the Nokia S40/S60 browsers and Chrome--all of which, except for the Opera browsers, are based on WebKit. I will give examples from the open source browsers Firefox and Chrome, and Safari (which is partly open source). According to [StatCounter statistics](http://gs.statcounter.com/) (as of June 2013) Chrome, Firefox and Safari make up around 71% of global desktop browser usage. On mobile, Android Browser, iPhone and Chrome constitute around 54% of usage. 91 | 92 | ## The browser's main functionality 93 | 94 | The main function of a browser is to present the web resource you choose, by requesting it from the server and displaying it in the browser window. The resource is usually an HTML document, but may also be a PDF, image, or some other type of content. The location of the resource is specified by the user using a URI (Uniform Resource Identifier). 95 | 96 | The way the browser interprets and displays HTML files is specified in the HTML and CSS specifications. These specifications are maintained by the W3C (World Wide Web Consortium) organization, which is the standards organization for the web. For years browsers conformed to only a part of the specifications and developed their own extensions. That caused serious compatibility issues for web authors. Today most of the browsers more or less conform to the specifications. 97 | 98 | Browser user interfaces have a lot in common with each other. Among the common user interface elements are: 99 | 100 | - Address bar for inserting a URI 101 | - Back and forward buttons 102 | - Bookmarking options 103 | - Refresh and stop buttons for refreshing or stopping the loading of current documents 104 | - Home button that takes you to your home page 105 | 106 | Strangely enough, the browser's user interface is not specified in any formal specification, it just comes from good practices shaped over years of experience and by browsers imitating each other. The HTML5 specification doesn't define UI elements a browser must have, but lists some common elements. Among those are the address bar, status bar and tool bar. There are, of course, features unique to a specific browser like Firefox's downloads manager. 107 | 108 | ## The browser's high level structure 109 | 110 | The browser's main components are ([1.1](#1-1)): 111 | 112 | 1. **The user interface**: this includes the address bar, back/forward button, bookmarking menu, etc. Every part of the browser display except the window where you see the requested page. 113 | 2. **The browser engine**: marshals actions between the UI and the rendering engine. 114 | 3. **The rendering engine **: responsible for displaying requested content. For example if the requested content is HTML, the rendering engine parses HTML and CSS, and displays the parsed content on the screen. 115 | 4. **Networking**: for network calls such as HTTP requests, using different implementations for different platform behind a platform-independent interface. 116 | 5. **UI backend**: used for drawing basic widgets like combo boxes and windows. This backend exposes a generic interface that is not platform specific. Underneath it uses operating system user interface methods. 117 | 6. **JavaScript interpreter**. Used to parse and execute JavaScript code. 118 | 7. **Data storage**. This is a persistence layer. The browser may need to save all sorts of data locally, such as cookies. Browsers also support storage mechanisms such as localStorage, IndexedDB, WebSQL and FileSystem. 119 | 120 | ![](images/bahtw_layers.png) 121 | 122 | Figure : Browser components 123 | 124 | It is important to note that browsers such as Chrome run multiple instances of the rendering engine: one for each tab. Each tab runs in a separate process. 125 | 126 | ## The rendering engine 127 | 128 | The responsibility of the rendering engine is well... Rendering, that is display of the requested contents on the browser screen. 129 | 130 | By default the rendering engine can display HTML and XML documents and images. It can display other types of data via plug-ins or extension; for example, displaying PDF documents using a PDF viewer plug-in. However, in this chapter we will focus on the main use case: displaying HTML and images that are formatted using CSS. 131 | 132 | ## Rendering engines 133 | 134 | Different browsers use different rendering engines: Internet Explorer uses Trident, Firefox uses Gecko, Safari uses WebKit. Chrome and Opera (from version 15) use Blink, a fork of WebKit. 135 | 136 | WebKit is an open source rendering engine which started as an engine for the Linux platform and was modified by Apple to support Mac and Windows. See [webkit.org](http://webkit.org/) for more details. 137 | 138 | ## The main flow 139 | 140 | The rendering engine will start getting the contents of the requested document from the networking layer. This will usually be done in 8kB chunks. 141 | 142 | After that, this is the basic flow of the rendering engine: 143 | 144 | ![](images/bahtw_flow.png) 145 | 146 | Figure : Rendering engine basic flow 147 | 148 | The rendering engine will start parsing the HTML document and convert elements to [DOM](#DOM) nodes in a tree called the "content tree". The engine will parse the style data, both in external CSS files and in style elements. Styling information together with visual instructions in the HTML will be used to create another tree: the [render tree](#Render-tree-construction). 149 | 150 | The render tree contains rectangles with visual attributes like color and dimensions. The rectangles are in the right order to be displayed on the screen. 151 | 152 | After the construction of the render tree it goes through a "[layout](#layout)" process. This means giving each node the exact coordinates where it should appear on the screen. The next stage is [painting](#Painting)--the render tree will be traversed and each node will be painted using the UI backend layer. 153 | 154 | It's important to understand that this is a gradual process. For better user experience, the rendering engine will try to display contents on the screen as soon as possible. It will not wait until all HTML is parsed before starting to build and layout the render tree. Parts of the content will be parsed and displayed, while the process continues with the rest of the contents that keeps coming from the network. 155 | 156 | ### Main flow examples 157 | 158 | ![](images/bahtw_webkitflow.png) 159 | 160 | **Figure : WebKit main flow** 161 | 162 | ![](images/bahtw_image008.jpg) 163 | 164 | **Figure : Mozilla's Gecko rendering engine main flow ([3.6](#3-6))** 165 | 166 | From figures 3 and 4 you can see that although WebKit and Gecko use slightly different terminology, the flow is basically the same. 167 | 168 | Gecko calls the tree of visually formatted elements a "Frame tree". Each element is a frame. WebKit uses the term "Render Tree" and it consists of "Render Objects". WebKit uses the term "layout" for the placing of elements, while Gecko calls it "Reflow". "Attachment" is WebKit's term for connecting DOM nodes and visual information to create the render tree. A minor non-semantic difference is that Gecko has an extra layer between the HTML and the DOM tree. It is called the "content sink" and is a factory for making DOM elements. We will talk about each part of the flow: 169 | 170 | ### Parsing--general 171 | 172 | Since parsing is a very significant process within the rendering engine, we will go into it a little more deeply. Let's begin with a little introduction about parsing. 173 | 174 | Parsing a document means translating it to a structure the code can use. The result of parsing is usually a tree of nodes that represent the structure of the document. This is called a parse tree or a syntax tree. 175 | 176 | For example, parsing the expression `2 + 3 - 1` could return this tree: 177 | 178 | ![](images/bahtw_image009.png) 179 | 180 | **Figure : mathematical expression tree node** 181 | 182 | ### Grammars 183 | 184 | Parsing is based on the syntax rules the document obeys: the language or format it was written in. Every format you can parse must have deterministic grammar consisting of vocabulary and syntax rules. It is called a [context free grammar](#context-free-grammar). Human languages are not such languages and therefore cannot be parsed with conventional parsing techniques. 185 | 186 | ### Parser--Lexer combination 187 | 188 | Parsing can be separated into two sub processes: lexical analysis and syntax analysis. 189 | 190 | Lexical analysis is the process of breaking the input into tokens. Tokens are the language vocabulary: the collection of valid building blocks. In human language it will consist of all the words that appear in the dictionary for that language. 191 | 192 | Syntax analysis is the applying of the language syntax rules. 193 | 194 | Parsers usually divide the work between two components: the **lexer** (sometimes called tokenizer) that is responsible for breaking the input into valid tokens, and the **parser** that is responsible for constructing the parse tree by analyzing the document structure according to the language syntax rules. The lexer knows how to strip irrelevant characters like white spaces and line breaks. 195 | 196 | ![](images/bahtw_image011.png) 197 | 198 | **Figure : from source document to parse trees** 199 | 200 | The parsing process is iterative. The parser will usually ask the lexer for a new token and try to match the token with one of the syntax rules. If a rule is matched, a node corresponding to the token will be added to the parse tree and the parser will ask for another token. 201 | 202 | If no rule matches, the parser will store the token internally, and keep asking for tokens until a rule matching all the internally stored tokens is found. If no rule is found then the parser will raise an exception. This means the document was not valid and contained syntax errors. 203 | 204 | ### Translation 205 | 206 | In many cases the parse tree is not the final product. Parsing is often used in translation: transforming the input document to another format. An example is compilation. The compiler that compiles source code into machine code first parses it into a parse tree and then translates the tree into a machine code document. 207 | 208 | ![](images/bahtw_image013.png) 209 | 210 | **Figure : compilation flow** 211 | 212 | ### Parsing example 213 | 214 | In figure 5 we built a parse tree from a mathematical expression. Let's try to define a simple mathematical language and see the parse process. 215 | 216 | Vocabulary: Our language can include integers, plus signs and minus signs. 217 | 218 | Syntax: 219 | 220 | 1. The language syntax building blocks are expressions, terms and operations. 221 | 2. Our language can include any number of expressions. 222 | 3. An expression is defined as a "term" followed by an "operation" followed by another term 223 | 4. An operation is a plus token or a minus token 224 | 5. A term is an integer token or an expression 225 | 226 | Let's analyze the input `2 + 3 - 1`.\ 227 | The first substring that matches a rule is `2`: according to rule #5 it is a term. The second match is `2 + 3`: this matches the third rule: a term followed by an operation followed by another term. The next match will only be hit at the end of the input. `2 + 3 - 1` is an expression because we already know that `2 + 3` is a term, so we have a term followed by an operation followed by another term. `2 + + `will not match any rule and therefore is an invalid input. 228 | 229 | ### Formal definitions for vocabulary and syntax 230 | 231 | Vocabulary is usually expressed by [regular expressions](http://www.regular-expressions.info/). 232 | 233 | For example our language will be defined as: 234 | 235 | > ```lang-html 236 | > INTEGER: 0|[1-9][0-9]\* 237 | > PLUS: + 238 | > MINUS: - 239 | > ``` 240 | 241 | As you see, integers are defined by a regular expression. 242 | 243 | Syntax is usually defined in a format called [BNF](http://en.wikipedia.org/wiki/Backus%E2%80%93Naur-Form). Our language will be defined as: 244 | 245 | > ```lang-html 246 | > expression := term operation term 247 | > operation := PLUS | MINUS 248 | > term := INTEGER | expression 249 | > ``` 250 | 251 | We said that a language can be parsed by regular parsers if its grammar is a context free grammar. An intuitive definition of a context free grammar is a grammar that can be entirely expressed in BNF. For a formal definition see [Wikipedia's article on Context-free grammar](http://en.wikipedia.org/wiki/Context-free-grammar) 252 | 253 | ### Types of parsers 254 | 255 | There are two types of parsers: top down parsers and bottom up parsers. An intuitive explanation is that top down parsers examine the high level structure of the syntax and try to find a rule match. Bottom up parsers start with the input and gradually transform it into the syntax rules, starting from the low level rules until high level rules are met. 256 | 257 | Let's see how the two types of parsers will parse our example. 258 | 259 | The top down parser will start from the higher level rule: it will identify `2 + 3` as an expression. It will then identify `2 + 3 - 1` as an expression (the process of identifying the expression evolves, matching the other rules, but the start point is the highest level rule). 260 | 261 | The bottom up parser will scan the input until a rule is matched. It will then replace the matching input with the rule. This will go on until the end of the input. The partly matched expression is placed on the parser's stack. 262 | 263 | | **Stack** | **Input** | 264 | | -------------------- | --------- | 265 | | | 2 + 3 - 1 | 266 | | term | + 3 - 1 | 267 | | term operation | 3 - 1 | 268 | | expression | - 1 | 269 | | expression operation | 1 | 270 | | expression | - | 271 | 272 | This type of bottom up parser is called a shift-reduce parser, because the input is shifted to the right (imagine a pointer pointing first at the input start and moving to the right) and is gradually reduced to syntax rules. 273 | 274 | ### Generating parsers automatically 275 | 276 | There are tools that can generate a parser. You feed them the grammar of your language--its vocabulary and syntax rules--and they generate a working parser. Creating a parser requires a deep understanding of parsing and it's not easy to create an optimized parser by hand, so parser generators can be very useful. 277 | 278 | WebKit uses two well known parser generators: [Flex](http://en.wikipedia.org/wiki/Flex-lexical-analyser) for creating a lexer and [Bison](http://www.gnu.org/software/bison/) for creating a parser (you might run into them with the names Lex and Yacc). Flex input is a file containing regular expression definitions of the tokens. Bison's input is the language syntax rules in BNF format. 279 | 280 | ## HTML Parser 281 | 282 | The job of the HTML parser is to parse the HTML markup into a parse tree. 283 | 284 | ### The HTML grammar definition 285 | 286 | The vocabulary and syntax of HTML are defined in [specifications](#w3c) created by the W3C organization. 287 | 288 | ### Not a context free grammar 289 | 290 | As we have seen in the parsing introduction, grammar syntax can be defined formally using formats like BNF. 291 | 292 | Unfortunately all the conventional parser topics do not apply to HTML (I didn't bring them up just for fun--they will be used in parsing CSS and JavaScript). HTML cannot easily be defined by a context free grammar that parsers need. 293 | 294 | There is a formal format for defining HTML--DTD (Document Type Definition)--but it is not a context free grammar. 295 | 296 | This appears strange at first sight; HTML is rather close to XML. There are lots of available XML parsers. There is an XML variation of HTML--XHTML--so what's the big difference? 297 | 298 | The difference is that the HTML approach is more "forgiving": it lets you omit certain tags (which are then added implicitly), or sometimes omit start or end tags, and so on. On the whole it's a "soft" syntax, as opposed to XML's stiff and demanding syntax. 299 | 300 | This seemingly small detail makes a world of a difference. On one hand this is the main reason why HTML is so popular: it forgives your mistakes and makes life easy for the web author. On the other hand, it makes it difficult to write a formal grammar. So to summarize, HTML cannot be parsed easily by conventional parsers, since its grammar is not context free. HTML cannot be parsed by XML parsers. 301 | 302 | ### HTML DTD 303 | 304 | HTML definition is in a DTD format. This format is used to define languages of the [SGML](http://en.wikipedia.org/wiki/Standard-Generalized-Markup-Language) family. The format contains definitions for all allowed elements, their attributes and hierarchy. As we saw earlier, the HTML DTD doesn't form a context free grammar. 305 | 306 | There are a few variations of the DTD. The strict mode conforms solely to the specifications but other modes contain support for markup used by browsers in the past. The purpose is backwards compatibility with older content. The current strict DTD is here: [www.w3.org/TR/html4/strict.dtd](http://www.w3.org/TR/html4/strict.dtd) 307 | 308 | ### DOM 309 | 310 | The output tree (the "parse tree") is a tree of DOM element and attribute nodes. DOM is short for Document Object Model. It is the object presentation of the HTML document and the interface of HTML elements to the outside world like JavaScript.\ 311 | The root of the tree is the "[Document](http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#i-Document)" object. 312 | 313 | The DOM has an almost one-to-one relation to the markup. For example: 314 | 315 | > ```lang-html 316 | >

Hello World

317 | > ``` 318 | 319 | This markup would be translated to the following DOM tree: 320 | 321 | ![](images/bahtw_image015.png) 322 | 323 | **Figure : DOM tree of the example markup** 324 | 325 | Like HTML, DOM is specified by the W3C organization. See [www.w3.org/DOM/DOMTR](http://www.w3.org/DOM/DOMTR). It is a generic specification for manipulating documents. A specific module describes HTML specific elements. The HTML definitions can be found here: [www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/idl-definitions.html](http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/idl-definitions.html). 326 | 327 | When I say the tree contains DOM nodes, I mean the tree is constructed of elements that implement one of the DOM interfaces. Browsers use concrete implementations that have other attributes used by the browser internally. 328 | 329 | #### The parsing algorithm 330 | 331 | As we saw in the previous sections, HTML cannot be parsed using the regular top down or bottom up parsers. 332 | 333 | The reasons are: 334 | 335 | 1. The forgiving nature of the language. 336 | 2. The fact that browsers have traditional error tolerance to support well known cases of invalid HTML. 337 | 3. The parsing process is reentrant. For other languages, the source doesn't change during parsing, but in HTML, dynamic code (such as script elements containing `document.write()` calls) can add extra tokens, so the parsing process actually modifies the input. 338 | 339 | Unable to use the regular parsing techniques, browsers create custom parsers for parsing HTML. 340 | 341 | The [parsing algorithm is described in detail by the HTML5 specification](http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html). The algorithm consists of two stages: tokenization and tree construction. 342 | 343 | Tokenization is the lexical analysis, parsing the input into tokens. Among HTML tokens are start tags, end tags, attribute names and attribute values. 344 | 345 | The tokenizer recognizes the token, gives it to the tree constructor, and consumes the next character for recognizing the next token, and so on until the end of the input. 346 | 347 | ![](images/bahtw_image017.png) 348 | 349 | **Figure : HTML parsing flow (taken from HTML5 spec)** 350 | 351 | ### The tokenization algorithm 352 | 353 | The algorithm's output is an HTML token. The algorithm is expressed as a state machine. Each state consumes one or more characters of the input stream and updates the next state according to those characters. The decision is influenced by the current tokenization state and by the tree construction state. This means the same consumed character will yield different results for the correct next state, depending on the current state. The algorithm is too complex to describe fully, so let's see a simple example that will help us understand the principle. 354 | 355 | Basic example--tokenizing the following HTML: 356 | 357 | > ```lang-html 358 | > Hello world 359 | > ``` 360 | 361 | The initial state is the "Data state". When the `<` character is encountered, the state is changed to **"Tag open state"**. Consuming an `a-z` character causes creation of a "Start tag token", the state is changed to **"Tag name state"**. We stay in this state until the `>` character is consumed. Each character is appended to the new token name. In our case the created token is an `html` token. 362 | 363 | When the `>` tag is reached, the current token is emitted and the state changes back to the **"Data state"**. The `` tag will be treated by the same steps. So far the `html` and `body` tags were emitted. We are now back at the **"Data state"**. Consuming the `H` character of `Hello world` will cause creation and emitting of a character token, this goes on until the `<` of `` is reached. We will emit a character token for each character of `Hello world`. 364 | 365 | We are now back at the **"Tag open state"**. Consuming the next input `/` will cause creation of an `end tag token` and a move to the **"Tag name state"**. Again we stay in this state until we reach `>`.Then the new tag token will be emitted and we go back to the **"Data state"**. The `` input will be treated like the previous case. 366 | 367 | ![](images/bahtw_image019.png) 368 | 369 | **Figure : Tokenizing the example input** 370 | 371 | #### Tree construction algorithm 372 | 373 | When the parser is created the Document object is created. During the tree construction stage the DOM tree with the Document in its root will be modified and elements will be added to it. Each node emitted by the tokenizer will be processed by the tree constructor. For each token the specification defines which DOM element is relevant to it and will be created for this token. The element is added to the DOM tree, and also the stack of open elements. This stack is used to correct nesting mismatches and unclosed tags. The algorithm is also described as a state machine. The states are called "insertion modes". 374 | 375 | Let's see the tree construction process for the example input: 376 | 377 | > ```lang-html 378 | > Hello world 379 | > ``` 380 | 381 | The input to the tree construction stage is a sequence of tokens from the tokenization stage. The first mode is the **"initial mode"**. Receiving the "html" token will cause a move to the **"before html"** mode and a reprocessing of the token in that mode. This will cause creation of the HTMLHtmlElement element, which will be appended to the root Document object. 382 | 383 | The state will be changed to **"before head"**. The "body" token is then received. An HTMLHeadElement will be created implicitly although we don't have a "head" token and it will be added to the tree. 384 | 385 | We now move to the **"in head"** mode and then to **"after head"**. The body token is reprocessed, an HTMLBodyElement is created and inserted and the mode is transferred to **"in body"**. 386 | 387 | The character tokens of the "Hello world" string are now received. The first one will cause creation and insertion of a "Text" node and the other characters will be appended to that node. 388 | 389 | The receiving of the body end token will cause a transfer to **"after body"** mode. We will now receive the html end tag which will move us to **"after after body"** mode. Receiving the end of file token will end the parsing. 390 | 391 | ![](images/bahtw_image022.gif) 392 | 393 | **Figure : tree construction of example html** 394 | 395 | ### Actions when the parsing is finished 396 | 397 | At this stage the browser will mark the document as interactive and start parsing scripts that are in "deferred" mode: those that should be executed after the document is parsed. The document state will be then set to "complete" and a "load" event will be fired. 398 | 399 | You can see [the full algorithms for tokenization and tree construction in the HTML5 specification](http://www.w3.org/TR/html5/syntax.html#html-parser) 400 | 401 | ### Browsers' error tolerance 402 | 403 | You never get an "Invalid Syntax" error on an HTML page. Browsers fix any invalid content and go on. 404 | 405 | Take this HTML for example: 406 | 407 | > ```lang-html 408 | >

Really lousy HTML

409 | > ``` 410 | 411 | I must have violated about a million rules ("mytag" is not a standard tag, wrong nesting of the "p" and "div" elements and more) but the browser still shows it correctly and doesn't complain. So a lot of the parser code is fixing the HTML author mistakes. 412 | 413 | Error handling is quite consistent in browsers, but amazingly enough it hasn't been part of HTML specifications. Like bookmarking and back/forward buttons it's just something that developed in browsers over the years. There are known invalid HTML constructs repeated on many sites, and the browsers try to fix them in a way conformant with other browsers. 414 | 415 | The HTML5 specification does define some of these requirements. (WebKit summarizes this nicely in the comment at the beginning of the HTML parser class.) 416 | 417 | > The parser parses tokenized input into the document, building up the document tree. If the document is well-formed, parsing it is straightforward. 418 | > 419 | > Unfortunately, we have to handle many HTML documents that are not well-formed, so the parser has to be tolerant about errors. 420 | > 421 | > We have to take care of at least the following error conditions: 422 | > 423 | > 1. The element being added is explicitly forbidden inside some outer tag. In this case we should close all tags up to the one which forbids the element, and add it afterwards. 424 | > 2. We are not allowed to add the element directly. It could be that the person writing the document forgot some tag in between (or that the tag in between is optional). This could be the case with the following tags: HTML HEAD BODY TBODY TR TD LI (did I forget any?). 425 | > 3. We want to add a block element inside an inline element. Close all inline elements up to the next higher block element. 426 | > 4. If this doesn't help, close elements until we are allowed to add the element--or ignore the tag. 427 | 428 | Let's see some WebKit error tolerance examples: 429 | 430 | `
instead of
` 431 | 432 | `Some sites use
instead of
. In order to be compatible with IE and Firefox, WebKit treats this like
.\` 433 | 434 | The code: 435 | 436 | > ```lang-html 437 | > if (t->isCloseTag(brTag) && m-document->inCompatMode()) { 438 | > reportError(MalformedBRError); t->beginTag = true; 439 | > } 440 | > ``` 441 | 442 | Note that the error handling is internal: it won't be presented to the user. 443 | 444 | #### A stray table 445 | 446 | A stray table is a table inside another table, but not inside a table cell. 447 | 448 | For example: 449 | 450 | > ```lang-html 451 | >
inner table
outer table 452 | > ``` 453 | 454 | WebKit will change the hierarchy to two sibling tables: 455 | 456 | > ```lang-html 457 | >
outer table
inner table
458 | > ``` 459 | 460 | The code: 461 | 462 | > ```lang-html 463 | > if (m-inStrayTableContent && localName == tableTag) 464 | > popBlock(tableTag); 465 | > ``` 466 | 467 | WebKit uses a stack for the current element contents: it will pop the inner table out of the outer table stack. The tables will now be siblings. 468 | 469 | #### Nested form elements 470 | 471 | In case the user puts a form inside another form, the second form is ignored.\ 472 | The code: 473 | 474 | > ```lang-html 475 | > if (!m-currentFormElement) { 476 | > m-currentFormElement = new HTMLFormElement(formTag, 477 | > m-document); } 478 | > ``` 479 | 480 | #### A too deep tag hierarchy 481 | 482 | The comment speaks for itself. 483 | 484 | > www.liceo.edu.mx is an example of a site that achieves a level of nesting of about 1500 tags, all from a bunch of ``s. We will only allow at most 20 nested tags of the same type before just ignoring them all together. 485 | 486 | > ```lang-html 487 | > bool HTMLParser::allowNestedRedundantTag(const AtomicString& tagName) 488 | > { 489 | > unsigned i = 0; 490 | > for (HTMLStackElem\* curr = m-blockStack; 491 | > i < cMaxRedundantTagDepth && curr && curr->tagName == 492 | > tagName; 493 | > curr = curr->next, i++) { } 494 | > return i != cMaxRedundantTagDepth; 495 | > } 496 | > ``` 497 | 498 | #### Misplaced html or body end tags 499 | 500 | Again--the comment speaks for itself. 501 | 502 | > Support for really broken HTML. We never close the body tag, since some stupid web pages close it before the actual end of the doc. Let's rely on the end() call to close things. 503 | 504 | > ```lang-html 505 | > if (t->tagName == htmlTag || t->tagName == bodyTag ) return; 506 | > ``` 507 | 508 | So web authors beware--unless you want to appear as an example in a WebKit error tolerance code snippet--write well formed HTML. 509 | 510 | ## CSS parsing 511 | 512 | Remember the parsing concepts in the introduction? Well, unlike HTML, CSS is a context free grammar and can be parsed using the types of parsers described in the introduction. In fact [the CSS specification defines CSS lexical and syntax grammar](http://www.w3.org/TR/CSS2/grammar.html). 513 | 514 | Let's see some examples:\ 515 | The lexical grammar (vocabulary) is defined by regular expressions for each token: 516 | 517 | > comment \/\*[^*]-\*+([^/-][^*]-\*+)-\/ 518 | > num [0-9]+|[0-9]-"."[0-9]+ 519 | > nonascii [\200-\377] 520 | > nmstart [-a-z]|{nonascii}|{escape} 521 | > nmchar [-a-z0-9-]|{nonascii}|{escape} 522 | > name {nmchar}+ 523 | > ident {nmstart}{nmchar}- 524 | 525 | "ident" is short for identifier, like a class name. "name" is an element id (that is referred by "#" ) 526 | 527 | The syntax grammar is described in BNF. 528 | 529 | > ```lang-bnf 530 | > ruleset 531 | > : selector [ ',' S* selector ]* 532 | > '{' S* declaration [ ';' S* declaration ]* '}' S* 533 | > ; 534 | > selector 535 | > : simple_selector [ combinator selector | S+ [ combinator? selector ]? ]? 536 | > ; 537 | > simple_selector 538 | > : element_name [ HASH | class | attrib | pseudo ]* 539 | > | [ HASH | class | attrib | pseudo ]+ 540 | > ; 541 | > class 542 | > : '.' IDENT 543 | > ; 544 | > element_name 545 | > : IDENT | '*' 546 | > ; 547 | > attrib 548 | > : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* 549 | > [ IDENT | STRING ] S* ] ']' 550 | > ; 551 | > pseudo 552 | > : ':' [ IDENT | FUNCTION S* [IDENT S*] ')' ] 553 | > ; 554 | > ``` 555 | 556 | Explanation: A ruleset is this structure: 557 | 558 | > ```lang-css 559 | > div.error, a.error { 560 | > color:red; 561 | > font-weight:bold; 562 | > } 563 | > ``` 564 | 565 | div.error and a.error are selectors. The part inside the curly braces contains the rules that are applied by this ruleset. This structure is defined formally in this definition: 566 | 567 | > ```lang-bnf 568 | > ruleset 569 | > : selector [ ',' S* selector ]* 570 | > '{' S* declaration [ ';' S* declaration ]* '}' S* 571 | > ; 572 | > ``` 573 | 574 | This means a ruleset is a selector or optionally a number of selectors separated by a comma and spaces (S stands for white space). A ruleset contains curly braces and inside them a declaration or optionally a number of declarations separated by a semicolon. "declaration" and "selector" will be defined in the following BNF definitions. 575 | 576 | ### WebKit CSS parser 577 | 578 | WebKit uses [Flex and Bison](#parser-generators) parser generators to create parsers automatically from the CSS grammar files. As you recall from the parser introduction, Bison creates a bottom up shift-reduce parser. Firefox uses a top down parser written manually. In both cases each CSS file is parsed into a StyleSheet object. Each object contains CSS rules. The CSS rule objects contain selector and declaration objects and other objects corresponding to CSS grammar. 579 | 580 | ![](images/bahtw_image023.png) 581 | 582 | **Figure : parsing CSS** 583 | 584 | ## The order of processing scripts and style sheets 585 | 586 | ### Scripts 587 | 588 | The model of the web is synchronous. Authors expect scripts to be parsed and executed immediately when the parser reaches a tag. The parsing of the document halts until the script has been executed. If the script is external then the resource must first be fetched from the network--this is also done synchronously, and parsing halts until the resource is fetched. This was the model for many years and is also specified in HTML4 and 5 specifications. Authors can add the "defer" attribute to a script, in which case it will not halt document parsing and will execute after the document is parsed. HTML5 adds an option to mark the script as asynchronous so it will be parsed and executed by a different thread. 589 | 590 | ### Speculative parsing 591 | 592 | Both WebKit and Firefox do this optimization. While executing scripts, another thread parses the rest of the document and finds out what other resources need to be loaded from the network and loads them. In this way, resources can be loaded on parallel connections and overall speed is improved. Note: the speculative parser only parses references to external resources like external scripts, style sheets and images: it doesn't modify the DOM tree--that is left to the main parser. 593 | 594 | ### Style sheets 595 | 596 | Style sheets on the other hand have a different model. Conceptually it seems that since style sheets don't change the DOM tree, there is no reason to wait for them and stop the document parsing. There is an issue, though, of scripts asking for style information during the document parsing stage. If the style is not loaded and parsed yet, the script will get wrong answers and apparently this caused lots of problems. It seems to be an edge case but is quite common. Firefox blocks all scripts when there is a style sheet that is still being loaded and parsed. WebKit blocks scripts only when they try to access certain style properties that may be affected by unloaded style sheets. 597 | 598 | ## Render tree construction 599 | 600 | While the DOM tree is being constructed, the browser constructs another tree, the render tree. This tree is of visual elements in the order in which they will be displayed. It is the visual representation of the document. The purpose of this tree is to enable painting the contents in their correct order. 601 | 602 | Firefox calls the elements in the render tree "frames". WebKit uses the term renderer or render object.\ 603 | A renderer knows how to lay out and paint itself and its children.\ 604 | WebKit's RenderObject class, the base class of the renderers, has the following definition: 605 | 606 | > ```lang-css 607 | > class RenderObject{ 608 | > virtual void layout(); 609 | > virtual void paint(PaintInfo); 610 | > virtual void rect repaintRect(); 611 | > Node* node; //the DOM node 612 | > RenderStyle* style; // the computed style 613 | > RenderLayer\* containgLayer; //the containing z-index layer 614 | > } 615 | > ``` 616 | 617 | Each renderer represents a rectangular area usually corresponding to a node's CSS box, as described by the CSS2 spec. It includes geometric information like width, height and position.\ 618 | The box type is affected by the "display" value of the style attribute that is relevant to the node (see the [style computation](#style-computation) section). Here is WebKit code for deciding what type of renderer should be created for a DOM node, according to the display attribute: 619 | 620 | > ```lang-css 621 | > RenderObject* RenderObject::createObject(Node* node, RenderStyle* style) 622 | > { 623 | > Document* doc = node->document(); 624 | > RenderArena* arena = doc->renderArena(); 625 | > ... 626 | > RenderObject* o = 0; 627 | > 628 | > switch (style->display()) { 629 | > case NONE: 630 | > break; 631 | > case INLINE: 632 | > o = new (arena) RenderInline(node); 633 | > break; 634 | > case BLOCK: 635 | > o = new (arena) RenderBlock(node); 636 | > break; 637 | > case INLINE-BLOCK: 638 | > o = new (arena) RenderBlock(node); 639 | > break; 640 | > case LIST-ITEM: 641 | > o = new (arena) RenderListItem(node); 642 | > break; 643 | > ... 644 | > } 645 | > return o; 646 | > } 647 | > ``` 648 | 649 | The element type is also considered: for example, form controls and tables have special frames.\ 650 | In WebKit if an element wants to create a special renderer, it will override the `createRenderer()` method. The renderers point to style objects that contains non geometric information. 651 | 652 | ### The render tree relation to the DOM tree 653 | 654 | The renderers correspond to DOM elements, but the relation is not one to one. Non-visual DOM elements will not be inserted in the render tree. An example is the "head" element. Also elements whose display value was assigned to "none" will not appear in the tree (whereas elements with "hidden" visibility will appear in the tree). 655 | 656 | There are DOM elements which correspond to several visual objects. These are usually elements with complex structure that cannot be described by a single rectangle. For example, the "select" element has three renderers: one for the display area, one for the drop down list box and one for the button. Also when text is broken into multiple lines because the width is not sufficient for one line, the new lines will be added as extra renderers.\ 657 | Another example of multiple renderers is broken HTML. According to the CSS spec an inline element must contain either only block elements or only inline elements. In the case of mixed content, anonymous block renderers will be created to wrap the inline elements. 658 | 659 | Some render objects correspond to a DOM node but not in the same place in the tree. Floats and absolutely positioned elements are out of flow, placed in a different part of the tree, and mapped to the real frame. A placeholder frame is where they should have been. 660 | 661 | ![](images/bahtw_image025.png) 662 | 663 | **Figure : The render tree and the corresponding DOM tree ([3.1](#3-1)). The "Viewport" is the initial containing block. In WebKit it will be the "RenderView" object** 664 | 665 | #### The flow of constructing the tree 666 | 667 | In Firefox, the presentation is registered as a listener for DOM updates. The presentation delegates frame creation to the `FrameConstructor` and the constructor resolves style (see [style computation](#style)) and creates a frame. 668 | 669 | In WebKit the process of resolving the style and creating a renderer is called "attachment". Every DOM node has an "attach" method. Attachment is synchronous, node insertion to the DOM tree calls the new node "attach" method. 670 | 671 | Processing the html and body tags results in the construction of the render tree root. The root render object corresponds to what the CSS spec calls the containing block: the top most block that contains all other blocks. Its dimensions are the viewport: the browser window display area dimensions. Firefox calls it `ViewPortFrame` and WebKit calls it `RenderView`. This is the render object that the document points to. The rest of the tree is constructed as a DOM nodes insertion. 672 | 673 | See [the CSS2 spec on the processing model](http://www.w3.org/TR/CSS21/intro.html#processing-model). 674 | 675 | ### Style Computation 676 | 677 | Building the render tree requires calculating the visual properties of each render object. This is done by calculating the style properties of each element. 678 | 679 | The style includes style sheets of various origins, inline style elements and visual properties in the HTML (like the "bgcolor" property).The later is translated to matching CSS style properties. 680 | 681 | The origins of style sheets are the browser's default style sheets, the style sheets provided by the page author and user style sheets--these are style sheets provided by the browser user (browsers let you define your favorite styles. In Firefox, for instance, this is done by placing a style sheet in the "Firefox Profile" folder). 682 | 683 | Style computation brings up a few difficulties: 684 | 685 | 1. Style data is a very large construct, holding the numerous style properties, this can cause memory problems. 686 | 2. Finding the matching rules for each element can cause performance issues if it's not optimized. Traversing the entire rule list for each element to find matches is a heavy task. Selectors can have complex structure that can cause the matching process to start on a seemingly promising path that is proven to be futile and another path has to be tried. 687 | 688 | For example--this compound selector: 689 | 690 | > ```lang-html 691 | > div div div div{ 692 | > ... 693 | > } 694 | > ``` 695 | 696 | Means the rules apply to a `
` who is the descendant of 3 divs. Suppose you want to check if the rule applies for a given `
` element. You choose a certain path up the tree for checking. You may need to traverse the node tree up just to find out there are only two divs and the rule does not apply. You then need to try other paths in the tree. 697 | 698 | 3. Applying the rules involves quite complex cascade rules that define the hierarchy of the rules. 699 | 700 | Let's see how the browsers face these issues: 701 | 702 | ### Sharing style data 703 | 704 | WebKit nodes references style objects (RenderStyle). These objects can be shared by nodes in some conditions. The nodes are siblings or cousins and: 705 | 706 | 1. The elements must be in the same mouse state (e.g., one can't be in :hover while the other isn't) 707 | 2. Neither element should have an id 708 | 3. The tag names should match 709 | 4. The class attributes should match 710 | 5. The set of mapped attributes must be identical 711 | 6. The link states must match 712 | 7. The focus states must match 713 | 8. Neither element should be affected by attribute selectors, where affected is defined as having any selector match that uses an attribute selector in any position within the selector at all 714 | 9. There must be no inline style attribute on the elements 715 | 10. There must be no sibling selectors in use at all. WebCore simply throws a global switch when any sibling selector is encountered and disables style sharing for the entire document when they are present. This includes the + selector and selectors like :first-child and :last-child. 716 | 717 | ### Firefox rule tree 718 | 719 | Firefox has two extra trees for easier style computation: the rule tree and style context tree. WebKit also has style objects but they are not stored in a tree like the style context tree, only the DOM node points to its relevant style. 720 | 721 | ![](images/bahtw_image035.png) 722 | 723 | **Figure : Firefox style context tree([2.2](#2-2))** 724 | 725 | The style contexts contain end values. The values are computed by applying all the matching rules in the correct order and performing manipulations that transform them from logical to concrete values. For example, if the logical value is a percentage of the screen it will be calculated and transformed to absolute units. The rule tree idea is really clever. It enables sharing these values between nodes to avoid computing them again. This also saves space. 726 | 727 | All the matched rules are stored in a tree. The bottom nodes in a path have higher priority. The tree contains all the paths for rule matches that were found. Storing the rules is done lazily. The tree isn't calculated at the beginning for every node, but whenever a node style needs to be computed the computed paths are added to the tree. 728 | 729 | The idea is to see the tree paths as words in a lexicon. Lets say we already computed this rule tree: 730 | 731 | ![](images/bahtw_tree.png) 732 | 733 | Suppose we need to match rules for another element in the content tree, and find out the matched rules (in the correct order) are B-E-I. We already have this path in the tree because we already computed path A-B-E-I-L. We will now have less work to do. 734 | 735 | Let's see how the tree saves us work. 736 | 737 | ### Division into structs 738 | 739 | The style contexts are divided into structs. Those structs contain style information for a certain category like border or color. All the properties in a struct are either inherited or non inherited. Inherited properties are properties that unless defined by the element, are inherited from its parent. Non inherited properties (called "reset" properties) use default values if not defined. 740 | 741 | The tree helps us by caching entire structs (containing the computed end values) in the tree. The idea is that if the bottom node didn't supply a definition for a struct, a cached struct in an upper node can be used. 742 | 743 | ### Computing the style contexts using the rule tree 744 | 745 | When computing the style context for a certain element, we first compute a path in the rule tree or use an existing one. We then begin to apply the rules in the path to fill the structs in our new style context. We start at the bottom node of the path--the one with the highest precedence (usually the most specific selector) and traverse the tree up until our struct is full. If there is no specification for the struct in that rule node, then we can greatly optimize--we go up the tree until we find a node that specifies it fully and simply point to it--that's the best optimization--the entire struct is shared. This saves computation of end values and memory.\ 746 | If we find partial definitions we go up the tree until the struct is filled. 747 | 748 | If we didn't find any definitions for our struct then, in case the struct is an "inherited" type, we point to the struct of our parent in the **context tree**. In this case we also succeeded in sharing structs. If it's a reset struct then default values will be used. 749 | 750 | If the most specific node does add values then we need to do some extra calculations for transforming it to actual values. We then cache the result in the tree node so it can be used by children. 751 | 752 | In case an element has a sibling or a brother that points to the same tree node then the **entire style context** can be shared between them. 753 | 754 | Lets see an example: Suppose we have this HTML 755 | 756 | > ```lang-html 757 | > 758 | > 759 | > 760 | >
761 | >

this is a big error this is also a very big error error

762 | >
763 | >
another error
764 | > 765 | > 766 | > 767 | > ``` 768 | 769 | And the following rules: 770 | 771 | > ```lang-html 772 | > 1. div {margin:5px;color:black} 773 | > 2. .err {color:red} 774 | > 3. .big {margin-top:3px} 775 | > 4. div span {margin-bottom:4px} 776 | > 5. #div1 {color:blue} 777 | > 6. #div2 {color:green} 778 | > ``` 779 | 780 | To simplify things let's say we need to fill out only two structs: the color struct and the margin struct. The color struct contains only one member: the color The margin struct contains the four sides.\ 781 | The resulting rule tree will look like this (the nodes are marked with the node name: the number of the rule they point at): 782 | 783 | ![](images/bahtw_image027.png) 784 | 785 | **Figure : The rule tree** 786 | 787 | The context tree will look like this (node name: rule node they point to): 788 | 789 | ![](images/bahtw_image029.png) 790 | 791 | **Figure : The context tree** 792 | 793 | Suppose we parse the HTML and get to the second
tag. We need to create a style context for this node and fill its style structs.\ 794 | We will match the rules and discover that the matching rules for the
are 1, 2 and 6. This means there is already an existing path in the tree that our element can use and we just need to add another node to it for rule 6 (node F in the rule tree).\ 795 | We will create a style context and put it in the context tree. The new style context will point to node F in the rule tree. 796 | 797 | We now need to fill the style structs. We will begin by filling out the margin struct. Since the last rule node (F) doesn't add to the margin struct, we can go up the tree until we find a cached struct computed in a previous node insertion and use it. We will find it on node B, which is the uppermost node that specified margin rules. 798 | 799 | We do have a definition for the color struct, so we can't use a cached struct. Since color has one attribute we don't need to go up the tree to fill other attributes. We will compute the end value (convert string to RGB etc) and cache the computed struct on this node. 800 | 801 | The work on the second element is even easier. We will match the rules and come to the conclusion that it points to rule G, like the previous span. Since we have siblings that point to the same node, we can share the entire style context and just point to the context of the previous span. 802 | 803 | For structs that contain rules that are inherited from the parent, caching is done on the context tree (the color property is actually inherited, but Firefox treats it as reset and caches it on the rule tree).\ 804 | For instance if we added rules for fonts in a paragraph: 805 | 806 | > ```lang-css 807 | > p {font-family: Verdana; font size: 10px; font-weight: bold} 808 | > ``` 809 | 810 | Then the paragraph element, which is a child of the div in the context tree, could have shared the same font struct as his parent. This is if no font rules were specified for the paragraph. 811 | 812 | In WebKit, who does not have a rule tree, the matched declarations are traversed four times. First non-important high priority properties are applied (properties that should be applied first because others depend on them, such as display), then high priority important, then normal priority non-important, then normal priority important rules. This means that properties that appear multiple times will be resolved according to the correct cascade order. The last wins. 813 | 814 | So to summarize: sharing the style objects (entirely or some of the structs inside them) solves issues [1](#issue1) and [3](#issue3). The Firefox rule tree also helps in applying the properties in the correct order. 815 | 816 | ### Manipulating the rules for an easy match 817 | 818 | There are several sources for style rules: 819 | 820 | - CSS rules, either in external style sheets or in style elements. 821 | 822 | > ```lang-css 823 | > p {color: blue} 824 | > ``` 825 | 826 | - Inline style attributes like 827 | 828 | > ```lang-html 829 | >

830 | > ``` 831 | 832 | - HTML visual attributes (which are mapped to relevant style rules) 833 | 834 | > ```lang-html 835 | >

836 | > ``` 837 | 838 | The last two are easily matched to the element since he owns the style attributes and HTML attributes can be mapped using the element as the key. 839 | 840 | As noted previously in [issue #2](#issue2), the CSS rule matching can be trickier. To solve the difficulty, the rules are manipulated for easier access. 841 | 842 | After parsing the style sheet, the rules are added to one of several hash maps, according to the selector. There are maps by id, by class name, by tag name and a general map for anything that doesn't fit into those categories. If the selector is an id, the rule will be added to the id map, if it's a class it will be added to the class map etc.\ 843 | This manipulation makes it much easier to match rules. There is no need to look in every declaration: we can extract the relevant rules for an element from the maps. This optimization eliminates 95+% of the rules, so that they need not even be considered during the matching process([4.1](#4-1)). 844 | 845 | Let's see for example the following style rules: 846 | 847 | > ```lang-css 848 | > p.error {color: red} 849 | > #messageDiv {height: 50px} 850 | > div {margin: 5px} 851 | > ``` 852 | 853 | The first rule will be inserted into the class map. The second into the id map and the third into the tag map.\ 854 | For the following HTML fragment; 855 | 856 | > ```lang-html 857 | >

an error occurred

858 | >
this is a message
859 | > ``` 860 | 861 | We will first try to find rules for the p element. The class map will contain an "error" key under which the rule for "p.error" is found. The div element will have relevant rules in the id map (the key is the id) and the tag map. So the only work left is finding out which of the rules that were extracted by the keys really match.\ 862 | For example if the rule for the div was 863 | 864 | > ```lang-css 865 | > table div {margin: 5px} 866 | > ``` 867 | 868 | it will still be extracted from the tag map, because the key is the rightmost selector, but it would not match our div element, who does not have a table ancestor. 869 | 870 | Both WebKit and Firefox do this manipulation. 871 | 872 | ### Applying the rules in the correct cascade order 873 | 874 | The style object has properties corresponding to every visual attribute (all CSS attributes but more generic). If the property is not defined by any of the matched rules, then some properties can be inherited by the parent element style object. Other properties have default values. 875 | 876 | The problem begins when there is more than one definition--here comes the cascade order to solve the issue. 877 | 878 | ### Style sheet cascade order 879 | 880 | A declaration for a style property can appear in several style sheets, and several times inside a style sheet. This means the order of applying the rules is very important. This is called the "cascade" order. According to CSS2 spec, the cascade order is (from low to high): 881 | 882 | 1. Browser declarations 883 | 2. User normal declarations 884 | 3. Author normal declarations 885 | 4. Author important declarations 886 | 5. User important declarations 887 | 888 | The browser declarations are least important and the user overrides the author only if the declaration was marked as important. Declarations with the same order will be sorted by [specificity](#Specificity) and then the order they are specified. The HTML visual attributes are translated to matching CSS declarations . They are treated as author rules with low priority. 889 | 890 | ### Specificity 891 | 892 | The selector specificity is defined by the [CSS2 specification](http://www.w3.org/TR/CSS2/cascade.html#specificity) as follows: 893 | 894 | - count 1 if the declaration it is from is a 'style' attribute rather than a rule with a selector, 0 otherwise (= a) 895 | - count the number of ID attributes in the selector (= b) 896 | - count the number of other attributes and pseudo-classes in the selector (= c) 897 | - count the number of element names and pseudo-elements in the selector (= d) 898 | 899 | Concatenating the four numbers a-b-c-d (in a number system with a large base) gives the specificity. 900 | 901 | The number base you need to use is defined by the highest count you have in one of the categories.\ 902 | For example, if a=14 you can use hexadecimal base. In the unlikely case where a=17 you will need a 17 digits number base. The later situation can happen with a selector like this: html body div div p ... (17 tags in your selector.. not very likely). 903 | 904 | Some examples: 905 | 906 | > ```lang-css 907 | > * {} /* a=0 b=0 c=0 d=0 -> specificity = 0,0,0,0 */ 908 | > li {} /* a=0 b=0 c=0 d=1 -> specificity = 0,0,0,1 */ 909 | > li:first-line {} /* a=0 b=0 c=0 d=2 -> specificity = 0,0,0,2 */ 910 | > ul li {} /* a=0 b=0 c=0 d=2 -> specificity = 0,0,0,2 */ 911 | > ul ol+li {} /* a=0 b=0 c=0 d=3 -> specificity = 0,0,0,3 */ 912 | > h1 + *[rel=up]{} /* a=0 b=0 c=1 d=1 -> specificity = 0,0,1,1 */ 913 | > ul ol li.red {} /* a=0 b=0 c=1 d=3 -> specificity = 0,0,1,3 */ 914 | > li.red.level {} /* a=0 b=0 c=2 d=1 -> specificity = 0,0,2,1 */ 915 | > #x34y {} /* a=0 b=1 c=0 d=0 -> specificity = 0,1,0,0 */ 916 | > style="" /* a=1 b=0 c=0 d=0 -> specificity = 1,0,0,0 */ 917 | > ``` 918 | 919 | ### Sorting the rules 920 | 921 | After the rules are matched, they are sorted according to the cascade rules. WebKit uses bubble sort for small lists and merge sort for big ones. WebKit implements sorting by overriding the ">" operator for the rules: 922 | 923 | > ```lang-c 924 | > static bool operator >(CSSRuleData& r1, CSSRuleData& r2) 925 | > { 926 | > int spec1 = r1.selector()->specificity(); 927 | > int spec2 = r2.selector()->specificity(); 928 | > return (spec1 == spec2) : r1.position() > r2.position() : spec1 > spec2; 929 | > } 930 | > ``` 931 | 932 | ### Gradual process 933 | 934 | WebKit uses a flag that marks if all top level style sheets (including @imports) have been loaded. If the style is not fully loaded when attaching, place holders are used and it is marked in the document, and they will be recalculated once the style sheets were loaded. 935 | 936 | ## Layout 937 | 938 | When the renderer is created and added to the tree, it does not have a position and size. Calculating these values is called layout or reflow. 939 | 940 | HTML uses a flow based layout model, meaning that most of the time it is possible to compute the geometry in a single pass. Elements later `in the flow'' typically do not affect the geometry of elements that are earlier `in the flow'', so layout can proceed left-to-right, top-to-bottom through the document. There are exceptions: for example, HTML tables may require more than one pass ([3.5](#3-5)). 941 | 942 | The coordinate system is relative to the root frame. Top and left coordinates are used. 943 | 944 | Layout is a recursive process. It begins at the root renderer, which corresponds to the `` element of the HTML document. Layout continues recursively through some or all of the frame hierarchy, computing geometric information for each renderer that requires it. 945 | 946 | The position of the root renderer is 0,0 and its dimensions are the viewport--the visible part of the browser window. 947 | 948 | All renderers have a "layout" or "reflow" method, each renderer invokes the layout method of its children that need layout. 949 | 950 | ### Dirty bit system 951 | 952 | In order not to do a full layout for every small change, browsers use a "dirty bit" system. A renderer that is changed or added marks itself and its children as "dirty": needing layout. 953 | 954 | There are two flags: "dirty", and "children are dirty" which means that although the renderer itself may be OK, it has at least one child that needs a layout. 955 | 956 | ### Global and incremental layout 957 | 958 | Layout can be triggered on the entire render tree--this is "global" layout. This can happen as a result of: 959 | 960 | 1. A global style change that affects all renderers, like a font size change. 961 | 2. As a result of a screen being resized 962 | 963 | Layout can be incremental, only the dirty renderers will be laid out (this can cause some damage which will require extra layouts).\ 964 | Incremental layout is triggered (asynchronously) when renderers are dirty. For example when new renderers are appended to the render tree after extra content came from the network and was added to the DOM tree. 965 | 966 | ![](images/bahtw_reflow.png) 967 | 968 | **Figure : Incremental layout--only dirty renderers and their children are laid out ([3.6](#3-6))** 969 | 970 | ### Asynchronous and Synchronous layout 971 | 972 | Incremental layout is done asynchronously. Firefox queues "reflow commands" for incremental layouts and a scheduler triggers batch execution of these commands. WebKit also has a timer that executes an incremental layout--the tree is traversed and "dirty" renderers are layout out.\ 973 | Scripts asking for style information, like "offsetHeight" can trigger incremental layout synchronously.\ 974 | Global layout will usually be triggered synchronously.\ 975 | Sometimes layout is triggered as a callback after an initial layout because some attributes, like the scrolling position changed. 976 | 977 | ### Optimizations 978 | 979 | When a layout is triggered by a "resize" or a change in the renderer position(and not size), the renders sizes are taken from a cache and not recalculated..\ 980 | In some cases only a sub tree is modified and layout does not start from the root. This can happen in cases where the change is local and does not affect its surroundings--like text inserted into text fields (otherwise every keystroke would trigger a layout starting from the root). 981 | 982 | ### The layout process 983 | 984 | The layout usually has the following pattern: 985 | 986 | 1. Parent renderer determines its own width. 987 | 2. Parent goes over children and: 988 | 1. Place the child renderer (sets its x and y). 989 | 2. Calls child layout if needed--they are dirty or we are in a global layout, or for some other reason--which calculates the child's height. 990 | 3. Parent uses children's accumulative heights and the heights of margins and padding to set its own height--this will be used by the parent renderer's parent. 991 | 4. Sets its dirty bit to false. 992 | 993 | Firefox uses a "state" object(nsHTMLReflowState) as a parameter to layout (termed "reflow"). Among others the state includes the parents width.\ 994 | The output of the Firefox layout is a "metrics" object(nsHTMLReflowMetrics). It will contain the renderer computed height. 995 | 996 | ### Width calculation 997 | 998 | The renderer's width is calculated using the container block's width, the renderer's style "width" property, the margins and borders.\ 999 | For example the width of the following div: 1000 | 1001 | > ```lang-html 1002 | >
1003 | > ``` 1004 | 1005 | Would be calculated by WebKit as the following(class RenderBox method calcWidth): 1006 | 1007 | - The container width is the maximum of the containers availableWidth and 0. The availableWidth in this case is the contentWidth which is calculated as: 1008 | 1009 | > ```lang-css 1010 | > clientWidth() - paddingLeft() - paddingRight() 1011 | > ``` 1012 | 1013 | clientWidth and clientHeight represent the interior of an object excluding border and scrollbar. 1014 | 1015 | - The elements width is the "width" style attribute. It will be calculated as an absolute value by computing the percentage of the container width. 1016 | - The horizontal borders and paddings are now added. 1017 | 1018 | So far this was the calculation of the "preferred width". Now the minimum and maximum widths will be calculated.\ 1019 | If the preferred width is greater then the maximum width, the maximum width is used. If it is less then the minimum width (the smallest unbreakable unit) then the minimum width is used. 1020 | 1021 | The values are cached in case a layout is needed, but the width does not change. 1022 | 1023 | ### Line Breaking 1024 | 1025 | When a renderer in the middle of a layout decides that it needs to break, the renderer stops and propagates to the layout's parent that it needs to be broken. The parent creates the extra renderers and calls layout on them. 1026 | 1027 | ## Painting 1028 | 1029 | In the painting stage, the render tree is traversed and the renderer's "paint()" method is called to display content on the screen. Painting uses the UI infrastructure component. 1030 | 1031 | ### Global and Incremental 1032 | 1033 | Like layout, painting can also be global--the entire tree is painted--or incremental. In incremental painting, some of the renderers change in a way that does not affect the entire tree. The changed renderer invalidates its rectangle on the screen. This causes the OS to see it as a "dirty region" and generate a "paint" event. The OS does it cleverly and coalesces several regions into one. In Chrome it is more complicated because the renderer is in a different process then the main process. Chrome simulates the OS behavior to some extent. The presentation listens to these events and delegates the message to the render root. The tree is traversed until the relevant renderer is reached. It will repaint itself (and usually its children). 1034 | 1035 | ### The painting order 1036 | 1037 | [CSS2 defines the order of the painting process](http://www.w3.org/TR/CSS21/zindex.html). This is actually the order in which the elements are stacked in the [stacking contexts](#stackingcontext). This order affects painting since the stacks are painted from back to front. The stacking order of a block renderer is: 1038 | 1039 | 1. background color 1040 | 2. background image 1041 | 3. border 1042 | 4. children 1043 | 5. outline 1044 | 1045 | ### Firefox display list 1046 | 1047 | Firefox goes over the render tree and builds a display list for the painted rectangular. It contains the renderers relevant for the rectangular, in the right painting order (backgrounds of the renderers, then borders etc). That way the tree needs to be traversed only once for a repaint instead of several times--painting all backgrounds, then all images, then all borders etc. 1048 | 1049 | Firefox optimizes the process by not adding elements that will be hidden, like elements completely beneath other opaque elements. 1050 | 1051 | #### WebKit rectangle storage 1052 | 1053 | Before repainting, WebKit saves the old rectangle as a bitmap. It then paints only the delta between the new and old rectangles. 1054 | 1055 | ### Dynamic changes 1056 | 1057 | The browsers try to do the minimal possible actions in response to a change. So changes to an element's color will cause only repaint of the element. Changes to the element position will cause layout and repaint of the element, its children and possibly siblings. Adding a DOM node will cause layout and repaint of the node. Major changes, like increasing font size of the "html" element, will cause invalidation of caches, relayout and repaint of the entire tree. 1058 | 1059 | ### The rendering engine's threads 1060 | 1061 | The rendering engine is single threaded. Almost everything, except network operations, happens in a single thread. In Firefox and Safari this is the main thread of the browser. In Chrome it's the tab process main thread.\ 1062 | Network operations can be performed by several parallel threads. The number of parallel connections is limited (usually 2--6 connections). 1063 | 1064 | ### Event loop 1065 | 1066 | The browser main thread is an event loop. It's an infinite loop that keeps the process alive. It waits for events (like layout and paint events) and processes them. This is Firefox code for the main event loop: 1067 | 1068 | > ```lang-c 1069 | > while (!mExiting) NS-ProcessNextEvent(thread); 1070 | > ``` 1071 | 1072 | ## CSS2 visual model 1073 | 1074 | ### The canvas 1075 | 1076 | According to the [CSS2 specification](http://www.w3.org/TR/CSS21/intro.html#processing-model), the term canvas describes "the space where the formatting structure is rendered": where the browser paints the content. The canvas is infinite for each dimension of the space but browsers choose an initial width based on the dimensions of the viewport. 1077 | 1078 | According to [www.w3.org/TR/CSS2/zindex.html](http://www.w3.org/TR/CSS2/zindex.html), the canvas is transparent if contained within another, and given a browser defined color if it is not. 1079 | 1080 | ### CSS Box model 1081 | 1082 | The [CSS box model](http://www.w3.org/TR/CSS2/box.html) describes the rectangular boxes that are generated for elements in the document tree and laid out according to the visual formatting model.\ 1083 | Each box has a content area (e.g. text, an image, etc.) and optional surrounding padding, border, and margin areas. 1084 | 1085 | ![](images/bahtw_image046.jpg) 1086 | 1087 | **Figure : CSS2 box model** 1088 | 1089 | Each node generates 0..n such boxes.\ 1090 | All elements have a "display" property that determines the type of box that will be generated. 1091 | 1092 | Examples: 1093 | 1094 | > ```lang-html 1095 | > block: generates a block box. 1096 | > inline: generates one or more inline boxes. 1097 | > none: no box is generated. 1098 | > ``` 1099 | 1100 | The default is inline but the browser style sheet may set other defaults. For example: the default display for the "div" element is block.\ 1101 | You can find a default style sheet example here: [www.w3.org/TR/CSS2/sample.html](http://www.w3.org/TR/CSS2/sample.html) 1102 | 1103 | ### Positioning scheme 1104 | 1105 | There are three schemes: 1106 | 1107 | 1. Normal: the object is positioned according to its place in the document. This means its place in the render tree is like its place in the DOM tree and laid out according to its box type and dimensions 1108 | 2. Float: the object is first laid out like normal flow, then moved as far left or right as possible 1109 | 3. Absolute: the object is put in the render tree in a different place than in the DOM tree 1110 | 1111 | The positioning scheme is set by the "position" property and the "float" attribute. 1112 | 1113 | - static and relative cause a normal flow 1114 | - absolute and fixed cause absolute positioning 1115 | 1116 | In static positioning no position is defined and the default positioning is used. In the other schemes, the author specifies the position: top, bottom, left, right. 1117 | 1118 | The way the box is laid out is determined by: 1119 | 1120 | - Box type 1121 | - Box dimensions 1122 | - Positioning scheme 1123 | - External information such as image size and the size of the screen 1124 | 1125 | ### Box types 1126 | 1127 | Block box: forms a block--has its own rectangle in the browser window. 1128 | 1129 | ![](images/bahtw_image057.png) 1130 | 1131 | **Figure : Block box** 1132 | 1133 | Inline box: does not have its own block, but is inside a containing block. 1134 | 1135 | ![](images/bahtw_image059.png) 1136 | 1137 | **Figure : Inline boxes** 1138 | 1139 | Blocks are formatted vertically one after the other. Inlines are formatted horizontally. 1140 | 1141 | ![](images/bahtw_image061.png) 1142 | 1143 | **Figure : Block and Inline formatting** 1144 | 1145 | Inline boxes are put inside lines or "line boxes". The lines are at least as tall as the tallest box but can be taller, when the boxes are aligned "baseline"--meaning the bottom part of an element is aligned at a point of another box other then the bottom. If the container width is not enough, the inlines will be put on several lines. This is usually what happens in a paragraph. 1146 | 1147 | ![](images/bahtw_image063.png) 1148 | 1149 | **Figure: Lines** 1150 | 1151 | ### Positioning 1152 | 1153 | #### Relative 1154 | 1155 | Relative positioning--positioned like usual and then moved by the required delta. 1156 | 1157 | ![](images/bahtw_image065.png) 1158 | 1159 | **Figure: Relative positioning** 1160 | 1161 | #### Floats 1162 | 1163 | A float box is shifted to the left or right of a line. The interesting feature is that the other boxes flow around it. The HTML: 1164 | 1165 | > ```lang-html 1166 | >

1167 | > 1168 | > Lorem ipsum dolor sit amet, consectetuer... 1169 | >

1170 | > ``` 1171 | 1172 | Will look like: 1173 | 1174 | ![](images/bahtw_image067.png) 1175 | 1176 | **Figure : Float** 1177 | 1178 | #### Absolute and fixed 1179 | 1180 | The layout is defined exactly regardless of the normal flow. The element does not participate in the normal flow. The dimensions are relative to the container. In fixed, the container is the viewport. 1181 | 1182 | ![](images/bahtw_image069.png) 1183 | 1184 | **Figure : Fixed positioning** 1185 | 1186 | Note: the fixed box will not move even when the document is scrolled! 1187 | 1188 | ### Layered representation 1189 | 1190 | This is specified by the z-index CSS property. It represents the third dimension of the box: its position along the "z axis". 1191 | 1192 | The boxes are divided into stacks (called stacking contexts). In each stack the back elements will be painted first and the forward elements on top, closer to the user. In case of overlap the foremost element will hide the former element.\ 1193 | The stacks are ordered according to the z-index property. Boxes with "z-index" property form a local stack. The viewport has the outer stack. 1194 | 1195 | Example: 1196 | 1197 | > ```lang-html 1198 | > 1205 | >

1206 | >

1207 | >
1208 | >

1209 | > ``` 1210 | 1211 | The result will be this: 1212 | 1213 | ![](images/bahtw_image071.png) 1214 | 1215 | **Figure : Fixed positioning** 1216 | 1217 | Although the red div precedes the green one in the markup, and would have been painted before in the regular flow, the z-index property is higher, so it is more forward in the stack held by the root box. 1218 | 1219 | ### Resources 1220 | 1221 | [How Browsers Work: Behind the scenes of modern web browsers](https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/) 1222 | -------------------------------------------------------------------------------- /internet/dns-and-how-it-works.md: -------------------------------------------------------------------------------- 1 | # Dns and How It Works? 2 | 3 | _© 2020 [John Otieno](https://linuxhint.com/author/otienojohn/) @ [linuxhint.com](https://linuxhint.com/), all rights reserved_ 4 | 5 | --- 6 | 7 | ## Contents 8 | 9 | 1. [Introduction](#introduction) 10 | 2. [What is DNS?](#what-is-dns) 11 | 3. [How DNS Works?](#how-dns-works) 12 | 4. [1: Domain Names](#domain-names) 13 | 5. [2: Nameservers](#nameservers) 14 | 6. [3: DNS Records and Zone Files](#dns-records-and-zone-files) 15 | 7. [4: DNS Resolution](#dns-resolution) 16 | 8. [Types of DNS Records](#types-of-dns-records) 17 | 9. [AXFR Records](#axfr-records) 18 | 10. [CNAME Records](#cname-records) 19 | 11. [CAA Records](#caa-records) 20 | 12. [DKIM Records](#dkim-recordsw) 21 | 13. [MX Records](#mx-records) 22 | 14. [NS Records](#ns-records) 23 | 15. [PTR Records](#ptr-records) 24 | 16. [SOA Records](#soa-records) 25 | 17. [TXT Records](#txt-records) 26 | 18. [SPF Records](#spf-records) 27 | 19. [SRV Records](#srv-records) 28 | 20. [Quick Dig Guide](#quick-dig-guide) 29 | 21. [Installing Dig](#installing-dig) 30 | 22. [Using Dig](#using-dig) 31 | 23. [Conclusion](#conclusion) 32 | 33 | ## Introduction 34 | 35 | _**Domain Name Systems,**_ or _**DNS**_, is an essential part of configuring networks, websites, and servers. 36 | 37 | When you learn how DNS works and how you can apply its use to real-life networks, diagnosing network problems becomes a breeze. Moreover, mastering the ins and outs of working with DNS will also give you a deep understanding of what goes on behind the scenes of DNS lookup and validations. 38 | 39 | This tutorial will help you learn fundamental DNS concepts that will help you get started with DNS configuration. After reading this guide, you should be able to modify DNS on your local system or even set up a personal DNS server. 40 | 41 | Before we dive into how to setup DNS servers and resolve domains, let’s go over some basic DNS concepts that’ll help you understand what DNS is and how it works. 42 | 43 | ## What is DNS? 44 | 45 | DNS or [Domain Name System](https://en.wikipedia.org/wiki/Domain_Name_System) is a database of Internet addresses indexed by domain names. For simplicity, think of DNS as an address book that forwards web traffic from a server to a client. 46 | 47 | DNS maps recognized domain names, such as linuxhint.com, to its IP address such as `**64.91.238.144**` (IPv4) or `**0:0:0:0:0:ffff:405b:ee90**` (IPv6). 48 | 49 | ## How DNS Works? 50 | 51 | Before discussing how to add and modify DNS records, let’s go over how DNS works, starting with defining some basic DNS features: 52 | 53 | ### Domain Names 54 | 55 | We can define Domain names as a unique string of characters that identifies an object within the internet. The object could represent a website, an IoT interface, etc. 56 | 57 | The best way to understand domain names is by reading them, starting from right towards the left. Comprehensive domain organization starts from the right and develops more specificity towards the left. 58 | 59 | Consider the example domains shown below: 60 | 61 | **linuxhint.com** 62 | 63 | **mail.info.linuxhint.com** 64 | 65 | In the examples above, the domains are best understood from right to left, with the TLD or Top-Level domain being **.com** 66 | 67 | Other terms that appear on the left of the TLD are separated by a period and are considered specific subdomains. 68 | 69 | For example: 70 | 71 | In this case, **mail.linuxhint.com** can only be used to handle mail for the specific domain. When referring to domains (main), it includes the first-level subdomain plus the TLD such as **linuxhint.com** 72 | 73 | As you move to the left of the TLD, **info,** and **mail** are referred to as second and third-level subdomains, correspondingly. 74 | 75 | In most cases, subdomains are used to identify specific services or machines. However, domain owners can use them in any way they see fit. 76 | 77 | ### Nameservers 78 | 79 | Nameservers are servers connected to the internet and used to handle queries about the location of a domain name and its services. 80 | 81 | Selecting and setting up name servers is an important responsibility of being a domain owner. That’s because if you do fail to set up name servers, devices that want to connect to your domain will be unable to know where to find the DNS information for your domain, leading to failed DNS domain resolve. 82 | 83 | Name servers use a text file called a zone file to host a domain’s DNS data. Zone files are sometimes called Start of Authority Records (SOA). You can host DNS information on name servers: 84 | 85 | - Provided by your domain registrar 86 | 87 | - Your own DNS Server 88 | 89 | - CDN hostings such as Cloudflare and any other third-party hosting 90 | 91 | Options such as hosting your DNS information on your own DNS server provide more control of the DNS process than most other options. 92 | 93 | ### DNS Records and Zone Files 94 | 95 | Another important DNS management concept is working with DNS records. These records help map domain names to their respective IP addresses and are bundled together to create a zone file. Devices can look up the correct IP address for your domain using the DNS zone files. 96 | 97 | Here’s an example of a DNS zone file: 98 | 99 | ![](images/dns1.png) 100 | 101 | In every DNS zone file, you will find default entries such as the administrator’s email, DNS records, and name servers. You are not limited to these default entries; you are allowed to create any number of DNS records for any subdomains possible. 102 | 103 | ### DNS Resolution 104 | 105 | The simplest way to understand how DNS works is by learning DNS resolution. 106 | 107 | Let’s talk about that: 108 | 109 | A domain name needs to be translated from a human-readable format, like linuxhint.com, to an IP address. That’s because machines only understand IP addresses, not domain names. 110 | 111 | As we have mentioned, this happens using the text zone file that stores a list of domains and their IP addresses. 112 | 113 | Thus: 114 | 115 | When you type a domain name such as linuxhint.com into your browser, your internet-connected device uses your ISP DNS resolver to query the root nameserver for the correct TLD nameserver. 116 | 117 | Think of it as your computer asking the resolver, “where can I find the nameserver for .com domains?” 118 | 119 | The root nameserver then replies with an IP address for the specified TLD. The DNS resolver uses the zone files from the domain’s nameserver to read which IP address points to the domain required. 120 | 121 | Once the ISP reads the domain’s IP address, for example, linuxhint.com, it replies to your browser, allowing you to access the webserver. 122 | 123 | ![](images/dns2.png) 124 | 125 | It’s good to note that the DNS resolution process only happens if the ISP DNS resolver has no record of the domain requested. In most cases, ISP performs DNS cache for previously queried domains, which leads to faster DNS lookups and less strain on the DNS servers. 126 | 127 | Although caching is a good thing, it can sometimes lead to issues, especially DNS information changes. You can use TTL or Time to Live to see the time it takes for a DNS to resolve. 128 | 129 | ![](images/dns3.png) 130 | 131 | Since you now know how DNS works, let’s discuss the types of DNS records. 132 | 133 | ## Types of DNS Records 134 | 135 | Here’re the main types of DNS records: 136 | 137 | **A and AAAA Records** 138 | 139 | The type _A DNS_ record is an IPv4 DNS record used to point to your server’s IP address, allowing web traffic to get to your server. 140 | 141 | Here’s an example of a type A DNS record: 142 | 143 | **linuxhint.com** **A** **64.91.238.144** 144 | 145 | **mail.linuxhint.com** **A** **64.91.238.144** 146 | 147 | DNS rules allow the pointing of multiple subdomains to varying IP addresses. You can also point all subdomains to a single IP address. For example. Point all subdomains for linuxhint.com to a single IP using an asterisk: 148 | 149 | **\*.linuxhint.com A 64.91.238.144** 150 | 151 | The _AAAA_ type record is similar to A record but is used for IPv6 IP addresses. A typical AAAA record may look similar to: 152 | 153 | **linuxhint.com AAAA 0456:7890:13ab:cdef:0145:5567:59ab:cdef** 154 | 155 | ## AXFR Records 156 | 157 | An _AXFR_ record is a DNS record used in DNS replication. AXFR records mainly apply to slave DNS servers where they help replicate zone files from master DNS servers. You will rarely find AXFR records in master zone files. 158 | 159 | It’s good to note that they are more efficient and modern ways to perform DNS replication other than using AXFR records. 160 | 161 | ## CNAME Records 162 | 163 | A _CNAME_ or _Canonical Name Record_ matches a domain to another domain. CNAME records allow DNS lookups to utilize the target domain’s DNS resolve as an alias resolution. Consider the example below: 164 | 165 | **aliasaddress.com CNAME linuxhint.com.** 166 | 167 | **linuxhint.com A 64.91.238.144** 168 | 169 | From the record: 170 | 171 | Once the DNS lookup for alias address.com gets performed, the process encounters a CNAME record that points to another address—in this case, linuxhint.com. 172 | 173 | It will initiate a new DNS lookup for the target address (linuxhint.com), which discovers the IP address of 64.91.238.144, thus directing the traffic to the IP address 64.91.238.144. 174 | 175 | The main purpose of CNAME records is to allow domains to have aliases. 176 | 177 | **NOTE:** Some mail servers use CNAME records to get mail. Therefore, it’s good to avoid using CNAME records for a domain designed to get mail. 178 | 179 | Similarly, you cannot use MX records to reference CNAME defined hostnames. It’s also good to ensure that target domains contain an A-record resolution. 180 | 181 | Although CNAME records can be an effective way to redirect traffic from a specific domain to another domain, the record does not function as HTTP 302 redirect. 182 | 183 | ## CAA Records 184 | 185 | CAA records allow domain owners to determine which certificate authorities can issue certificates for that specific domain. 186 | 187 | ## DKIM Records 188 | 189 | _DKIM_ or _Domain Keys Identified Mail Record_ shows the public keys used to authenticate messages signed by the DKIM protocol. It enhances the functionality of checking the authenticity of mail. 190 | 191 | A typical DKIM record may look as follows: 192 | 193 | **selector1.\_domainkey.linuxhint.com TXT k=rsa;p=J7eTBu445i045iK** 194 | 195 | DKIM DNS records are applied as TXT record type. They get created from a subdomain with a unique selector for that specific key followed by a period, ending with **\_domainkey.domain.com** (linuxhint.com). 196 | 197 | From the example above, we see the DKIM record of type TXT, a value that shows the key type (RSA), and finally, the key value. 198 | 199 | ## MX Records 200 | 201 | MX or Mail Exchanger records help set the mail delivery destinations for a specific domain or subdomains. 202 | 203 | Here’s an example of an MX record: 204 | 205 | **linuxhint.com MX preference = 5, mail exchanger = ALT1.ASPMX.L.GOOGLE.com** 206 | 207 | **linuxhint.com MX preference = 1, mail exchanger = ASPMX.L.GOOGLE.com** 208 | 209 | **linuxhint.com MX preference = 5, mail exchanger = ALT2.ASPMX.L.GOOGLE.com** 210 | 211 | **linuxhint.com MX preference = 10, mail exchanger = ALT4.ASPMX.L.GOOGLE.com** 212 | 213 | **linuxhint.com MX preference = 10, mail exchanger = ALT3.ASPMX.L.GOOGLE.com** 214 | 215 | The record in the example above directs mail for domain (linuxhint.com) to the server ALT1.ASPMX.L.GOOGLE.COM 216 | 217 | Priority or preference is a key component of MX records. It is used to represent the number written between the record type and the target server. Low numbers are used to indicate higher priority. 218 | 219 | For example, if server **ASPMX.L.GOOGLE.COM** is down, the mail gets delivered to **ALT1.ASPMX.L.GOOGLE.COM or ALT2.ASPMX.L.GOOGLE.COM** 220 | 221 | ## NS Records 222 | 223 | NS or Nameserver records are the most common type of DNS records. 224 | 225 | They are used to set the nameservers for a domain or subdomain. By default, the NS records for a domain are set both in your zone file and the domain registrar. 226 | 227 | Here’s an example of NS records: 228 | 229 | **linuxhint.com nameserver = ns1.liquidweb.com** 230 | 231 | **linuxhint.com nameserver = ns.liquidweb.com** 232 | 233 | Nameservers set at the domain registrar are responsible for carrying the zone file for the domain. 234 | 235 | You can also add more than nameservers for your domain and subdomains. NS records for subdomains are configured in the primary domain zone file. 236 | 237 | Primary nameservers are configured at the domain registrar. Secondary domain nameservers are configured at the primary domain’s zone file. NS records order does not matter because DNS requests get sent in a random pattern to different servers. This ensures that if one host fails to respond, the other hosts will get queried. 238 | 239 | ## PTR Records 240 | 241 | PTR records, also called pointer records, are used for a reverse DNS lookup. They mainly match an IP address to a domain or a subdomain. You can consider the PTR record the opposite of A or AAAA records; its functions are opposite to those of the A record. 242 | 243 | An A record allows you to look up a domain related to a specific IP address. On the other hand, PTR records allow you to look up the IP address associated with a specific domain name. These records are mainly set by a hosting provider and are not included in your zone file. 244 | 245 | You must create a valid A record that points the domain to the target IP address before creating a PTR record. Use A record for IPv4 address and AAAA for IPv6 addresses. 246 | 247 | DNS rules allow you to have different IP addresses, both IPv4 and IPv6 pointing to the same domain set for reverse DNS by configuring multiple A and AAAA records for a specific domain pointing to various IP addresses. 248 | 249 | ## SOA Records 250 | 251 | SOA or Start of Authority records is used by DNS to label a zone file with the host’s name where it was originally created. It also displays the email address of the individual who owns the domain. 252 | 253 | Here’s an example of a typical SOA record: 254 | 255 | **@ IN SOA ns.liquidweb.com. admin.liquidweb.com. 20200627 14000 14000 1009600** 256 | 257 | **86400** 258 | 259 | **NOTE:** The administrative email is expressed using a period (.) and not an @ symbol. 260 | 261 | SOA records include the following values: 262 | 263 | - **Serial Number:** This represents the revision number for the domain’s zone file; the value changes once a file gets restructured. 264 | 265 | - **Refresh Time:** Represents the total amount of time a secondary DNS server keeps the server before updating it to the latest changes. The value is represented in seconds. 266 | 267 | - **Retry Time:** Represents the amount of time a secondary DNS server waits before retrying for a failed zone file transfer. 268 | 269 | - **Expire Time:** This shows the amount of time a server waits before expiring and copying a zone file if updating the file fails. 270 | 271 | - **Minimum Time to Live:** This shows the min amount of time other servers keep the zone file’s cached information. 272 | 273 | The name server stated in the SOA record is regarded as the primary master for use in the Dynamic DNS. The Dynamic DNS is the server where zone file updates get completed before being propagated to other nameservers. 274 | 275 | ## TXT Records 276 | 277 | A Text or TXT record is used to provide information about a specific domain to other network resources. TXT records are a very flexible record type. They can serve a wide range of operations depending on the contents of a specific text value. 278 | 279 | One common use of TXT records is creating DKIM records and SPF records. Here is an example of a TXT record: 280 | 281 | **linuxhint.com text =** 282 | 283 | **“google-site-verification=tf_9zclZLNBJ5M…XXX…\_0nSA”** 284 | 285 | ## SPF Records 286 | 287 | Sender Policy Framework records the list for the mail servers of a specific domain or subdomain. SPF records help prove a mail server’s authenticity by flagging spoofing attempts deployed using the common method of faking email headers for a specific domain, making it look like it originates from a legit server, thus evading filters. 288 | 289 | Here’s an example of an SPF record: 290 | 291 | **linuxhint.com TXT “v=spf1 a ~all”** 292 | 293 | It is recommended to list all the servers in the SPF record you use to send mail and exclude the others. 294 | 295 | The SPF record mainly has a domain, type (TXT or SPF if supported), and a value starting with v=spf1, which contains SPF record settings. 296 | 297 | To ensure your emails don’t get flagged as spam, ensure the SPF records are not too strict or exclude the server you use to send emails. 298 | 299 | ## SRV Records 300 | 301 | Service records or SRV help match services running on a domain to target domains, allowing you to direct traffic from specific services to another. 302 | 303 | Here’s an example of an SRV record: 304 | 305 | **\_service.\_protocol.linuxhint.com SRV 10 0 8080** 306 | 307 | **service.linuxhint.com** 308 | 309 | SRV records have the following elements: 310 | 311 | - **Service:** This indicates the service name, which starts with an underscore, the name, and ends with a period. 312 | 313 | - **Protocol:** This is the name of the protocol. It also has an underscore at the beginning of its name and ending with a period symbol. Example: **\_tcp or \_udp** 314 | 315 | - **Domain:** This is the domain name receiving the initial traffic before forwarding. 316 | 317 | - **Priority:** This sets the priority for the target domain. You are allowed to set multiple targets having different priorities, thus allowing you to have a fallback if a server fails. 318 | 319 | - **Port:** This is the port where the service is running. TCP or UDP port. 320 | 321 | - **Target:** Refers to the target domain. Ensure the domain has an A record that resolves to its target IP address. 322 | 323 | - **The target domain or subdomain:** This domain must have an A or AAAA record that resolves to an IP address. 324 | 325 | ## Quick Dig Guide 326 | 327 | Using a manual query tool is one of the best ways to understand and work with DNS. Let’s go over how to install and perform simple DNS queries using the Dig tool. 328 | 329 | You can use additional tools such as **nslookup.** 330 | 331 | ## Installing Dig 332 | 333 | Dig is a command-line utility used to perform manual DNS queries and DNS diagnostics. 334 | 335 | Before we can use dig, we need to install it. Dig is a part of DNS utilities in the Bind DNS server package, and you can install these packages using the package manager for your distribution. 336 | 337 | ## Debian & Ubuntu 338 | 339 | **apt-get install dnsutils** 340 | 341 | ## CentOS 342 | 343 | **yum install bind-utils** 344 | 345 | ## Using Dig 346 | 347 | Consider the following simple dig output. 348 | 349 | ![](images/dns4.png) 350 | 351 | From the above query, dig returns a NOERROR result and retrieves the A DNS record for the domain name linuxhint.com, which resolves to the IP address of 64.91.238.144. 352 | 353 | Using dig, you can see more information, plus the DNS resolver used (1.1.1.1 – Cloudflare), the amount of time a DNS query takes to complete, as well as the query size. 354 | 355 | ## Use dig to Retrieve Different Record Types 356 | 357 | You can use dig to retrieve information about specific DNS records by specifying the DNS record type in the command. 358 | 359 | Consider the displayed output below: 360 | 361 | ![](images/dns5.png) 362 | 363 | A dig is a popular tool that can be very helpful when you’re working with DNS. You can learn more from its manual or a tutorial. 364 | 365 | ## Conclusion 366 | 367 | In this article, we have learned what DNS is and how it works. We have covered important DNS concepts such as Domain names, DNS resolution and records, and how to use the Dig tool to examine DNS. 368 | 369 | Using this guide, you should be in a position to manage and configure basic DNS functionalities. 370 | -------------------------------------------------------------------------------- /internet/how-does-the-internet-work.md: -------------------------------------------------------------------------------- 1 | 2 | How Does the Internet Work? 3 | =========================== 4 | 5 | _© 2002 [Rus Shuler](mailto:russhuler@yahoo.com) @ [Pomeroy IT Solutions](http://www.pomeroy.com/), all rights reserved_ 6 | 7 | * * * 8 | 9 | Contents 10 | -------- 11 | 12 | 1. [Introduction](#introduction) 13 | 2. [Where to Begin? Internet Addresses](#where-to-begin-internet-addresses) 14 | 3. [Protocol Stacks and Packets](#protocol-stacks-and-packets) 15 | 4. [Networking Infrastructure](#networking-infrastructure) 16 | 5. [Internet Infrastructure](#internet-infrastructure) 17 | 6. [The Internet Routing Hierarchy](#the-internet-routing-hierarchy) 18 | 7. [Domain Names and Address Resolution](#domain-names-and-address-resolution) 19 | 8. [Internet Protocols Revisited](#internet-protocols-revisited) 20 | 9. [Application Protocols: HTTP and the World Wide Web](#application-protocols-http-and-the-world-wide-web) 21 | 10. [Application Protocols: SMTP and Electronic Mail](#application-protocols-smtp-and-electronic-mail) 22 | 11. [Transmission Control Protocol](#transmission-control-protocol) 23 | 12. [Internet Protocol](#internet-protocol) 24 | 13. [Wrap Up](#wrap-up) 25 | 14. [Resources](#resources) 26 | 15. [Bibliography](#bibliography) 27 | 28 | ## Introduction 29 | 30 | How does the Internet work? Good question! The Internet's growth has become explosive and it seems impossible to escape the bombardment of _www.com_'s seen constantly on television, heard on radio, and seen in magazines. Because the Internet has become such a large part of our lives, a good understanding is needed to use this new tool most effectively. 31 | 32 | This whitepaper explains the underlying infrastructure and technologies that make the Internet work. It does not go into great depth, but covers enough of each area to give a basic understanding of the concepts involved. For any unanswered questions, a list of resources is provided at the end of the paper. Any comments, suggestions, questions, etc. are encouraged and may be directed to the author at rshuler@gobcg.com. 33 | 34 | ## Where to Begin? Internet Addresses 35 | 36 | Because the Internet is a global network of computers each computer connected to the Internet **must** have a unique address. Internet addresses are in the form **nnn.nnn.nnn.nnn** where nnn must be a number from 0 - 255. This address is known as an IP address. (IP stands for Internet Protocol; more on this later.) 37 | 38 | The picture below illustrates two computers connected to the Internet; your computer with IP address 1.2.3.4 and another computer with IP address 5.6.7.8. The Internet is represented as an abstract object in-between. (As this paper progresses, the Internet portion of Diagram 1 will be explained and redrawn several times as the details of the Internet are exposed.) 39 | 40 | ![Diagram 1](images/ruswp_diag1.gif) 41 | 42 | Diagram 1 43 | 44 | If you connect to the Internet through an Internet Service Provider (ISP), you are usually assigned a temporary IP address for the duration of your dial-in session. If you connect to the Internet from a local area network (LAN) your computer might have a permanent IP address or it might obtain a temporary one from a DHCP (Dynamic Host Configuration Protocol) server. In any case, if you are connected to the Internet, your computer has a unique IP address. 45 | 46 | > **Check It Out - The Traceroute Program** 47 | > 48 | > If you're using Microsoft Windows or a flavor of Unix and have a 49 | > connection to the Internet, here is another handy Internet program. 50 | > This one is called **traceroute** and it shows the path your packets 51 | > are taking to a given Internet destination. Like ping, you must use 52 | > traceroute from a command prompt. In Windows, use tracert 53 | > www.yahoo.com. From a Unix prompt, type traceroute www.yahoo.com. Like 54 | > ping, you may also enter IP addresses instead of domain names. 55 | > Traceroute will print out a list of all the routers, computers, and 56 | > any other Internet entities that your packets must travel through to 57 | > get to their destination. 58 | 59 | 60 | ## Protocol Stacks and Packets 61 | 62 | So your computer is connected to the Internet and has a unique address. How does it 'talk' to other computers connected to the Internet? An example should serve here: Let's say your IP address is 1.2.3.4 and you want to send a message to the computer 5.6.7.8. The message you want to send is "Hello computer 5.6.7.8!". Obviously, the message must be transmitted over whatever kind of wire connects your computer to the Internet. Let's say you've dialed into your ISP from home and the message must be transmitted over the phone line. Therefore the message must be translated from alphabetic text into electronic signals, transmitted over the Internet, then translated back into alphabetic text. How is this accomplished? Through the use of a **protocol stack**. Every computer needs one to communicate on the Internet and it is usually built into the computer's operating system (i.e. Windows, Unix, etc.). The protocol stack used on the Internet is refered to as the TCP/IP protocol stack because of the two major communication protocols used. The TCP/IP stack looks like this: 63 | 64 | | Protocol Layer | Comments | 65 | |--|--| 66 | | Application Protocols Layer |Protocols specific to applications such as WWW, e-mail, FTP, etc. | 67 | | Transmission Control Protocol Layer | TCP directs packets to a specific application on a computer using a port number. | 68 | | Internet Protocol Layer | IP directs packets to a specific computer using an IP address. | 69 | | Hardware Layer | Converts binary packet data to network signals and back. (E.g. ethernet network card, modem for phone lines, etc.)| 70 | 71 | 72 | 73 | If we were to follow the path that the message "Hello computer 5.6.7.8!" took from our computer to the computer with IP address 5.6.7.8, it would happen something like this: 74 | 75 | 76 | ![Diagram 2](images/ruswp_diag2.gif) 77 | 78 | Diagram 2 79 | 80 | 1. The message would start at the top of the protocol stack on your computer and work it's way downward. 81 | 2. If the message to be sent is long, each stack layer that the message passes through may break the message up into smaller chunks of data. This is because data sent over the Internet (and most computer networks) are sent in manageable chunks. On the Internet, these chunks of data are known as **packets**. 82 | 3. The packets would go through the Application Layer and continue to the TCP layer. Each packet is assigned a **port number**. Ports will be explained later, but suffice to say that many programs may be using the TCP/IP stack and sending messages. We need to know which program on the destination computer needs to receive the message because it will be listening on a specific port. 83 | 4. After going through the TCP layer, the packets proceed to the IP layer. This is where each packet receives it's destination address, 5.6.7.8. 84 | 5. Now that our message packets have a port number and an IP address, they are ready to be sent over the Internet. The hardware layer takes care of turning our packets containing the alphabetic text of our message into electronic signals and transmitting them over the phone line. 85 | 6. On the other end of the phone line your ISP has a direct connection to the Internet. The ISPs **router** examines the destination address in each packet and determines where to send it. Often, the packet's next stop is another router. More on routers and Internet infrastructure later. 86 | 7. Eventually, the packets reach computer 5.6.7.8. Here, the packets start at the bottom of the destination computer's TCP/IP stack and work upwards. 87 | 8. As the packets go upwards through the stack, all routing data that the sending computer's stack added (such as IP address and port number) is stripped from the packets. 88 | 9. When the data reaches the top of the stack, the packets have been re-assembled into their original form, "Hello computer 5.6.7.8!" 89 | 90 | 91 | ## Networking Infrastructure 92 | 93 | So now you know how packets travel from one computer to another over the Internet. But what's in-between? What actually makes up the Internet? Let's look at another diagram: 94 | 95 | 96 | ![Diagram 3](images/ruswp_diag3.gif) 97 | 98 | Diagram 3 99 | 100 | Here we see Diagram 1 redrawn with more detail. The physical connection through the phone network to the Internet Service Provider might have been easy to guess, but beyond that might bear some explanation. 101 | 102 | The ISP maintains a pool of modems for their dial-in customers. This is managed by some form of computer (usually a dedicated one) which controls data flow from the modem pool to a backbone or dedicated line router. This setup may be refered to as a port server, as it 'serves' access to the network. Billing and usage information is usually collected here as well. 103 | 104 | After your packets traverse the phone network and your ISP's local equipment, they are routed onto the ISP's backbone or a backbone the ISP buys bandwidth from. From here the packets will usually journey through several routers and over several backbones, dedicated lines, and other networks until they find their destination, the computer with address 5.6.7.8. But wouldn't it would be nice if we knew the exact route our packets were taking over the Internet? As it turns out, there is a way... 105 | 106 | **Check It Out - The Traceroute Program** 107 | 108 | If you're using Microsoft Windows or a flavor of Unix and have a connection to the Internet, here is another handy Internet program. This one is called **traceroute** and it shows the path your packets are taking to a given Internet destination. Like ping, you must use traceroute from a command prompt. In Windows, use tracert www.yahoo.com. From a Unix prompt, type traceroute www.yahoo.com. Like ping, you may also enter IP addresses instead of domain names. Traceroute will print out a list of all the routers, computers, and any other Internet entities that your packets must travel through to get to their destination. 109 | 110 | 111 | If you use traceroute, you'll notice that your packets must travel through many things to get to their destination. Most have long names such as sjc2-core1-h2-0-0.atlas.digex.net and fddi0-0.br4.SJC.globalcenter.net. These are Internet routers that decide where to send your packets. Several routers are shown in Diagram 3, but only a few. Diagram 3 is meant to show a simple network structure. The Internet is much more complex. 112 | 113 | ## Internet Infrastructure 114 | 115 | The Internet backbone is made up of many large networks which interconnect with each other. These large networks are known as **Network Service Providers** or **NSP**s. Some of the large NSPs are UUNet, CerfNet, IBM, BBN Planet, SprintNet, PSINet, as well as others. These networks **peer** with each other to exchange packet traffic. Each NSP is required to connect to three **Network Access Points** or **NAP**s. At the NAPs, packet traffic may jump from one NSP's backbone to another NSP's backbone. NSPs also interconnect at **Metropolitan Area Exchanges** or **MAE**s. MAEs serve the same purpose as the NAPs but are privately owned. NAPs were the original Internet interconnect points. Both NAPs and MAEs are referred to as Internet Exchange Points or **IX**s. NSPs also sell bandwidth to smaller networks, such as ISPs and smaller bandwidth providers. Below is a picture showing this hierarchical infrastructure. 116 | 117 | ![Diagram 4](images/ruswp_diag4.gif) 118 | 119 | Diagram 4 120 | 121 | This is not a true representation of an actual piece of the Internet. Diagram 4 is only meant to demonstrate how the NSPs could interconnect with each other and smaller ISPs. None of the physical network components are shown in Diagram 4 as they are in Diagram 3. This is because a single NSP's backbone infrastructure is a complex drawing by itself. Most NSPs publish maps of their network infrastructure on their web sites and can be found easily. To draw an actual map of the Internet would be nearly impossible due to it's size, complexity, and ever changing structure. 122 | 123 | ## The Internet Routing Hierarchy 124 | 125 | So how do packets find their way across the Internet? Does every computer connected to the Internet know where the other computers are? Do packets simply get 'broadcast' to every computer on the Internet? The answer to both the preceeding questions is 'no'. No computer knows where any of the other computers are, and packets do not get sent to every computer. The information used to get packets to their destinations are contained in routing tables kept by each router connected to the Internet. 126 | 127 | **Routers are packet switches.** A router is usually connected between networks to route packets between them. Each router knows about it's sub-networks and which IP addresses they use. The router usually doesn't know what IP addresses are 'above' it. Examine Diagram 5 below. The black boxes connecting the backbones are routers. The larger NSP backbones at the top are connected at a NAP. Under them are several sub-networks, and under them, more sub-networks. At the bottom are two local area networks with computers attached. 128 | 129 | 130 | ![Diagram 5](images/ruswp_diag5.gif) 131 | 132 | Diagram 5 133 | 134 | 135 | 136 | When a packet arrives at a router, the router examines the IP address put there by the IP protocol layer on the originating computer. The router checks it's routing table. If the network containing the IP address is found, the packet is sent to that network. If the network containing the IP address is not found, then the router sends the packet on a default route, usually up the backbone hierarchy to the next router. Hopefully the next router will know where to send the packet. If it does not, again the packet is routed upwards until it reaches a NSP backbone. The routers connected to the NSP backbones hold the largest routing tables and here the packet will be routed to the correct backbone, where it will begin its journey 'downward' through smaller and smaller networks until it finds it's destination. 137 | 138 | Domain Names and Address Resolution 139 | 140 | But what if you don't know the IP address of the computer you want to connect to? What if the you need to access a web server referred to as _www.anothercomputer.com_? How does your web browser know where on the Internet this computer lives? The answer to all these questions is the **Domain Name Service** or **DNS**. The DNS is a distributed database which keeps track of computer's names and their corresponding IP addresses on the Internet. 141 | 142 | Many computers connected to the Internet host part of the DNS database and the software that allows others to access it. These computers are known as DNS servers. No DNS server contains the entire database; they only contain a subset of it. If a DNS server does not contain the domain name requested by another computer, the DNS server re-directs the requesting computer to another DNS server. 143 | 144 | 145 | ![Diagram 6](images/ruswp_diag6.gif) 146 | 147 | Diagram 6 148 | 149 | The Domain Name Service is structured as a hierarchy similar to the IP routing hierarchy. The computer requesting a name resolution will be re-directed 'up' the hierarchy until a DNS server is found that can resolve the domain name in the request. Figure 6 illustrates a portion of the hierarchy. At the top of the tree are the domain roots. Some of the older, more common domains are seen near the top. What is not shown are the multitude of DNS servers around the world which form the rest of the hierarchy. 150 | 151 | When an Internet connection is setup (e.g. for a LAN or Dial-Up Networking in Windows), one primary and one or more secondary DNS servers are usually specified as part of the installation. This way, any Internet applications that need domain name resolution will be able to function correctly. For example, when you enter a web address into your web browser, the browser first connects to your primary DNS server. After obtaining the IP address for the domain name you entered, the browser then connects to the target computer and requests the web page you wanted. 152 | 153 | > **Check It Out - Disable DNS in Windows** 154 | > 155 | > If you're using Windows 95/NT and access the Internet, you may view 156 | > your DNS server(s) and even disable them. 157 | > 158 | > _If you use Dial-Up Networking:_ Open your Dial-Up Networking window (which can be found in Windows Explorer under your CD-ROM drive and 159 | > above Network Neighborhood). Right click on your Internet connection 160 | > and click Properties. Near the bottom of the connection properties 161 | > window press the TCP/IP Settings... button. 162 | > 163 | > _If you have a permanent connection to the Internet:_ Right click on Network Neighborhood and click Properties. Click TCP/IP Properties. 164 | > Select the DNS Configuration tab at the top. 165 | > 166 | > You should now be looking at your DNS servers' IP addresses. Here you 167 | > may disable DNS or set your DNS servers to 0.0.0.0. (Write down your 168 | > DNS servers' IP addresses first. You will probably have to restart 169 | > Windows as well.) Now enter an address into your web browser. The 170 | > browser won't be able to resolve the domain name and you will probably 171 | > get a nasty dialog box explaining that a DNS server couldn't be found. 172 | > However, if you enter the corresponding IP address instead of the 173 | > domain name, the browser will be able to retrieve the desired web 174 | > page. (Use ping to get the IP address prior to disabling DNS.) Other 175 | > Microsoft operating systems are similar. 176 | 177 | 178 | 179 | ## Internet Protocols Revisited 180 | 181 | As hinted to earlier in the section about protocol stacks, one may surmise that there are many protocols that are used on the Internet. This is true; there are many communication protocols required for the Internet to function. These include the TCP and IP protocols, routing protocols, medium access control protocols, application level protocols, etc. The following sections describe some of the more important and commonly used protocols on the Internet. Higher level protocols are discussed first, followed by lower level protocols. 182 | 183 | ## Application Protocols: HTTP and the World Wide Web 184 | 185 | One of the most commonly used services on the Internet is the World Wide Web (WWW). The application protocol that makes the web work is **Hypertext Transfer Protocol** or **HTTP**. Do not confuse this with the Hypertext Markup Language (HTML). HTML is the language used to write web pages. HTTP is the protocol that web browsers and web servers use to communicate with each other over the Internet. It is an application level protocol because it sits on top of the TCP layer in the protocol stack and is used by specific applications to talk to one another. In this case the applications are web browsers and web servers. 186 | 187 | HTTP is a connectionless text based protocol. Clients (web browsers) send requests to web servers for web elements such as web pages and images. After the request is serviced by a server, the connection between client and server across the Internet is disconnected. A new connection must be made for each request. Most protocols are connection oriented. This means that the two computers communicating with each other keep the connection open over the Internet. HTTP does not however. Before an HTTP request can be made by a client, a new connection must be made to the server. 188 | 189 | When you type a URL into a web browser, this is what happens: 190 | 191 | 1. If the URL contains a domain name, the browser first connects to a domain name server and retrieves the corresponding IP address for the web server. 192 | 2. The web browser connects to the web server and sends an HTTP request (via the protocol stack) for the desired web page. 193 | 3. The web server receives the request and checks for the desired page. If the page exists, the web server sends it. If the server cannot find the requested page, it will send an HTTP 404 error message. (404 means 'Page Not Found' as anyone who has surfed the web probably knows.) 194 | 4. The web browser receives the page back and the connection is closed. 195 | 5. The browser then parses through the page and looks for other page elements it needs to complete the web page. These usually include images, applets, etc. 196 | 6. For each element needed, the browser makes additional connections and HTTP requests to the server for each element. 197 | 7. When the browser has finished loading all images, applets, etc. the page will be completely loaded in the browser window. 198 | 199 | > **Check It Out - Use Your Telnet Client to Retrieve a Web Page Using HTTP** 200 | > 201 | > Telnet is a remote terminal service used on the Internet. It's use has 202 | > declined lately, but it is a very useful tool to study the Internet. 203 | > In Windows find the default telnet program. It may be located in the 204 | > Windows directory named telnet.exe. When opened, pull down the 205 | > Terminal menu and select Preferences. In the preferences window, check 206 | > Local Echo. (This is so you can see your HTTP request when you type 207 | > it.) Now pull down the Connection menu and select Remote System. Enter 208 | > www.google.com for the Host Name and 80 for the Port. (Web servers 209 | > usually listen on port 80 by default.) Press Connect. Now type 210 | > 211 | > GET / HTTP/1.0 212 | > 213 | > and press Enter twice. This is a simple HTTP request to a web server 214 | > for it's root page. You should see a web page flash by and then a 215 | > dialog box should pop up to tell you the connection was lost. If you'd 216 | > like to save the retrieved page, turn on logging in the Telnet 217 | > program. You may then browse through the web page and see the HTML 218 | > that was used to write it. 219 | 220 | 221 | Most Internet protocols are specified by Internet documents known as a **Request For Comments** or **RFC**s. RFCs may be found at several locations on the Internet. See the Resources section below for appropriate URL's. HTTP version 1.0 is specified by RFC 1945. 222 | 223 | ## Application Protocols: SMTP and Electronic Mail 224 | 225 | Another commonly used Internet service is electronic mail. E-mail uses an application level protocol called **Simple Mail Transfer Protocol** or **SMTP**. SMTP is also a text based protocol, but unlike HTTP, SMTP is connection oriented. SMTP is also more complicated than HTTP. There are many more commands and considerations in SMTP than there are in HTTP. 226 | 227 | When you open your mail client to read your e-mail, this is what typically happens: 228 | 229 | 1. The mail client (Netscape Mail, Lotus Notes, Microsoft Outlook, etc.) opens a connection to it's default mail server. The mail server's IP address or domain name is typically setup when the mail client is installed. 230 | 2. The mail server will always transmit the first message to identify itself. 231 | 3. The client will send an SMTP HELO command to which the server will respond with a 250 OK message. 232 | 4. Depending on whether the client is checking mail, sending mail, etc. the appropriate SMTP commands will be sent to the server, which will respond accordingly. 233 | 5. This request/response transaction will continue until the client sends an SMTP QUIT command. The server will then say goodbye and the connection will be closed. 234 | 235 | A simple 'conversation' between an SMTP client and SMTP server is shown below. **R:** denotes messages sent by the server (receiver) and **S:** denotes messages sent by the client (sender). This SMTP example shows mail sent by Smith at host USC-ISIF, to 236 | Jones, Green, and Brown at host BBN-UNIX. Here we assume that 237 | host USC-ISIF contacts host BBN-UNIX directly. The mail is 238 | accepted for Jones and Brown. Green does not have a mailbox at 239 | host BBN-UNIX. 240 | 241 | ------------------------------------------------------------- 242 | 243 | R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready 244 | S: HELO USC-ISIF.ARPA 245 | R: 250 BBN-UNIX.ARPA 246 | 247 | S: MAIL FROM: 248 | R: 250 OK 249 | 250 | S: RCPT TO: 251 | R: 250 OK 252 | 253 | S: RCPT TO: 254 | R: 550 No such user here 255 | 256 | S: RCPT TO: 257 | R: 250 OK 258 | 259 | S: DATA 260 | R: 354 Start mail input; end with . 261 | S: Blah blah blah... 262 | S: ...etc. etc. etc. 263 | S: . 264 | R: 250 OK 265 | 266 | S: QUIT 267 | R: 221 BBN-UNIX.ARPA Service closing transmission channel This SMTP transaction is taken from RFC 821, which specifies SMTP. 268 | 269 | ## Transmission Control Protocol 270 | 271 | Under the application layer in the protocol stack is the TCP layer. When applications open a connection to another computer on the Internet, the messages they send (using a specific application layer protocol) get passed down the stack to the TCP layer. **TCP is responsible for routing application protocols to the correct application on the destination computer**. To accomplish this, port numbers are used. Ports can be thought of as seperate channels on each computer. For example, you can surf the web while reading e-mail. This is because these two applications (the web browser and the mail client) used different port numbers. When a packet arrives at a computer and makes its way up the protocol stack, the TCP layer decides which application receives the packet based on a port number. 272 | 273 | TCP works like this: 274 | 275 | * When the TCP layer receives the application layer protocol data from above, it segments it into manageable 'chunks' and then adds a TCP header with specific TCP information to each 'chunk'. The information contained in the TCP header includes the port number of the application the data needs to be sent to. 276 | * When the TCP layer receives a packet from the IP layer below it, the TCP layer strips the TCP header data from the packet, does some data reconstruction if necessary, and then sends the data to the correct application using the port number taken from the TCP header. 277 | 278 | This is how TCP routes the data moving through the protocol stack to the correct application. 279 | 280 | TCP is not a textual protocol. **TCP is a connection-oriented, reliable, byte stream service**. Connection-oriented means that two applications using TCP must first establish a connection before exchanging data. TCP is reliable because for each packet received, an acknowledgement is sent to the sender to confirm the delivery. TCP also includes a checksum in it's header for error-checking the received data. The TCP header looks like this: 281 | 282 | 283 | ![Diagram 7](images/ruswp_diag7.gif) 284 | 285 | Diagram 7 286 | 287 | 288 | 289 | Notice that there is no place for an IP address in the TCP header. This is because TCP doesn't know anything about IP addresses. TCP's job is to get application level data from application to application reliably. The task of getting data from computer to computer is the job of IP. 290 | 291 | **Check It Out - Well Known Internet Port Numbers** 292 | 293 | Listed below are the port numbers for some of the more commonly used Internet services. 294 | 295 | | Service | Port | 296 | |--|--| 297 | | Ftp | 20/21 | 298 | | Telnet | 23 | 299 | | SSH | 22 | 300 | | Telnet | 23 | 301 | | SMTP | 25 | 302 | | DNS | 53 | 303 | | DHCP | 67, 68 | 304 | | TFTP | 69 | 305 | | HTTP | 80 | 306 | | POP3 | 110 | 307 | | NNTP |119 | 308 | | NTP | 123 | 309 | | IMAP4 | 143 | 310 | | LDAP |389 | 311 | | HTTPS | 443 | 312 | | IMAPS |993 | 313 | | RADIUS | 1812 | 314 | |AIM | 5190 | 315 | 316 | 317 | 318 | ## Internet Protocol 319 | 320 | Unlike TCP, **IP is an unreliable, connectionless protocol**. IP doesn't care whether a packet gets to it's destination or not. Nor does IP know about connections and port numbers. **IP's job is too send and route packets to other computers**. IP packets are independent entities and may arrive out of order or not at all. It is TCP's job to make sure packets arrive and are in the correct order. About the only thing IP has in common with TCP is the way it receives data and adds it's own IP header information to the TCP data. The IP header looks like this: 321 | 322 | 323 | ![Diagram 8](images/ruswp_diag8.gif) 324 | 325 | Diagram 8 326 | 327 | 328 | 329 | Above we see the IP addresses of the sending and receiving computers in the IP header. Below is what a packet looks like after passing through the application layer, TCP layer, and IP layer. The application layer data is segmented in the TCP layer, the TCP header is added, the packet continues to the IP layer, the IP header is added, and then the packet is transmitted across the Internet. 330 | 331 | 332 | ![Diagram 9](images/ruswp_diag9.gif) 333 | 334 | Diagram 9 335 | 336 | 337 | 338 | ## Wrap Up 339 | 340 | Now you know how the Internet works. But how long will it stay this way? The version of IP currently used on the Internet (version 4) only allows 232 addresses. Eventually there won't be any free IP addresses left. Surprised? Don't worry. IP version 6 is being tested right now on a research backbone by a consortium of research institutions and corporations. And after that? Who knows. The Internet has come a long way since it's inception as a Defense Department research project. No one really knows what the Internet will become. One thing is sure, however. The Internet will unite the world like no other mechanism ever has. The Information Age is in full stride and I am glad to be a part of it. 341 | 342 | Rus Shuler, 1998 343 | Updates made 2002 344 | 345 | ## Resources 346 | 347 | Main resource of this article: 348 | [https://web.stanford.edu/class/msande91si/www-spr04/readings/week1/InternetWhitepaper.htm](https://web.stanford.edu/class/msande91si/www-spr04/readings/week1/InternetWhitepaper.htm) 349 | 350 | Below are some interesting links associated with some of the topics discussed. (I hope they all still work. All open in new window.) 351 | 352 | [http://www.ietf.org/](http://www.ietf.org/) is the home page of the Internet Engineering Task Force. This body is greatly responsible for the development of Internet protocols and the like. 353 | 354 | [http://www.internic.org/](http://www.internic.org/) is the organization responsible for administering domain names. 355 | 356 | [http://www.nexor.com/public/rfc/index/rfc.html](http://www.nexor.com/public/rfc/index/rfc.html) is an excellent RFC search engine useful for finding any RFC. 357 | 358 | [http://www.internetweather.com/](http://www.internetweather.com/) shows animated maps of Internet latency. 359 | 360 | [http://routes.clubnet.net/iw/](http://routes.clubnet.net/iw/) is Internet Weather from ClubNET. This page shows packet loss for various carriers. 361 | 362 | [http://navigators.com/isp.html](http://navigators.com/isp.html) is Russ Haynal's ISP Page. This is a great site with links to most NSPs and their backbone infrastructure maps. 363 | 364 | ## Bibliography 365 | 366 | The following books are excellent resources and helped greatly in the writing of this paper. I believe Stevens' book is the best TCP/IP reference ever and can be considered the bible of the Internet. Sheldon's book covers a much wider scope and contains a vast amount of networking information. 367 | 368 | * TCP/IP Illustrated, Volume 1, The Protocols. 369 | W. Richard Stevens. 370 | Addison-Wesley, Reading, Massachusetts. 1994. 371 | * Encyclopedia of Networking. 372 | Tom Sheldon. 373 | Osbourne McGraw-Hill, New York. 1998. 374 | 375 | Although not used for writing this paper, here are some other good books on the topics of the Internet and networking: 376 | 377 | * Firewalls and Internet Security; Repelling the Wiley Hacker. 378 | William R. Cheswick, Steven M. Bellovin. 379 | Addison-Wesley, Reading, Massachusetts. 1994. 380 | * Data Communications, Computer Networks and Open Systems. Fourth Edition. 381 | Fred Halsall. 382 | Addison-Wesley, Harlow, England. 1996. 383 | * Telecommunications: Protocols and Design. 384 | John D. Spragins with Joseph L. Hammond and Krzysztof Pawlikowski. 385 | Addison-Wesley, Reading, Massachusetts. 1992. -------------------------------------------------------------------------------- /internet/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/.DS_Store -------------------------------------------------------------------------------- /internet/images/bahtw_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_flow.png -------------------------------------------------------------------------------- /internet/images/bahtw_image008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image008.jpg -------------------------------------------------------------------------------- /internet/images/bahtw_image009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image009.png -------------------------------------------------------------------------------- /internet/images/bahtw_image011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image011.png -------------------------------------------------------------------------------- /internet/images/bahtw_image013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image013.png -------------------------------------------------------------------------------- /internet/images/bahtw_image015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image015.png -------------------------------------------------------------------------------- /internet/images/bahtw_image017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image017.png -------------------------------------------------------------------------------- /internet/images/bahtw_image019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image019.png -------------------------------------------------------------------------------- /internet/images/bahtw_image022.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image022.gif -------------------------------------------------------------------------------- /internet/images/bahtw_image023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image023.png -------------------------------------------------------------------------------- /internet/images/bahtw_image025.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image025.png -------------------------------------------------------------------------------- /internet/images/bahtw_image027.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image027.png -------------------------------------------------------------------------------- /internet/images/bahtw_image029.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image029.png -------------------------------------------------------------------------------- /internet/images/bahtw_image035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image035.png -------------------------------------------------------------------------------- /internet/images/bahtw_image046.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image046.jpg -------------------------------------------------------------------------------- /internet/images/bahtw_image057.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image057.png -------------------------------------------------------------------------------- /internet/images/bahtw_image059.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image059.png -------------------------------------------------------------------------------- /internet/images/bahtw_image061.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image061.png -------------------------------------------------------------------------------- /internet/images/bahtw_image063.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image063.png -------------------------------------------------------------------------------- /internet/images/bahtw_image065.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image065.png -------------------------------------------------------------------------------- /internet/images/bahtw_image067.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image067.png -------------------------------------------------------------------------------- /internet/images/bahtw_image069.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image069.png -------------------------------------------------------------------------------- /internet/images/bahtw_image071.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_image071.png -------------------------------------------------------------------------------- /internet/images/bahtw_layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_layers.png -------------------------------------------------------------------------------- /internet/images/bahtw_reflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_reflow.png -------------------------------------------------------------------------------- /internet/images/bahtw_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_tree.png -------------------------------------------------------------------------------- /internet/images/bahtw_webkitflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/bahtw_webkitflow.png -------------------------------------------------------------------------------- /internet/images/cgiarch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/cgiarch.gif -------------------------------------------------------------------------------- /internet/images/dns1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/dns1.png -------------------------------------------------------------------------------- /internet/images/dns2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/dns2.png -------------------------------------------------------------------------------- /internet/images/dns3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/dns3.png -------------------------------------------------------------------------------- /internet/images/dns4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/dns4.png -------------------------------------------------------------------------------- /internet/images/dns5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/dns5.png -------------------------------------------------------------------------------- /internet/images/ruswp_diag1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag1.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag2.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag3.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag4.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag5.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag6.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag7.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag8.gif -------------------------------------------------------------------------------- /internet/images/ruswp_diag9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/ruswp_diag9.gif -------------------------------------------------------------------------------- /internet/images/wiadn_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/internet/images/wiadn_structure.png -------------------------------------------------------------------------------- /internet/index.md: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae suscipit ligula, sed vulputate velit. Vivamus scelerisque metus quis ligula volutpat tincidunt at non felis. Donec ut maximus lorem, eu mollis eros. Duis ac enim sed tortor lacinia maximus sit amet eget eros. Morbi fermentum dui neque, sit amet ornare quam tristique nec. Sed tristique nisi diam, vel cursus quam vulputate et. Praesent diam orci, consectetur ut gravida luctus, rutrum at odio. -------------------------------------------------------------------------------- /internet/what-is-domain-name.md: -------------------------------------------------------------------------------- 1 | # What is a Domain Name? 2 | 3 | _© [mdn web docs](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_domain_name) - Jul 11, 2022, all rights reserved_ 4 | 5 | --- 6 | 7 | Prerequisites: First you need to know [how the Internet works](https://muratdemirci.github.io/backend-dev-roadmap/#/./internet/how-does-the-internet-work) and understand [what URLs are](/en-US/docs/Learn/Common_questions/What_is_a_URL). Objective: Learn what domain names are, how they work, and why they are important. 8 | 9 | # Contents 10 | 11 | 1. [Introduction](#introduction) 12 | 2. [Deeper dive](#deeper-dive) 13 | 3. [Structure of domain names](#structure-of-domain-names) 14 | 4. [Buying a domain name](#buying-a-domain-name) 15 | 5. [Dns and How It Works?](#dns-and-how-it-works) 16 | 17 | ## [Introduction](#introduction) 18 | 19 | Domain names are a key part of the Internet infrastructure. They provide a human-readable address for any web server available on the Internet. 20 | 21 | Any Internet-connected computer can be reached through a public IP address, either an IPv4 address (e.g. `173.194.121.32`) or an IPv6 address (e.g., `2027:0da8:8b73:0000:0000:8a2e:0370:1337`). 22 | 23 | Computers can handle such addresses easily, but people have a hard time finding out who's running the server or what service the website offers. IP addresses are hard to remember and might change over time. 24 | 25 | To solve all those problems we use human-readable addresses called domain names. 26 | 27 | ## [Deeper dive](#deeper-dive) 28 | 29 | ### [Structure of domain names](#structure-of-domain-names) 30 | 31 | A domain name has a simple structure made of several parts (it might be one part only, two, three…), separated by dots and **read from right to left**: 32 | 33 | ![Anatomy of the MDN domain name](images/wiadn_structure.png) 34 | 35 | Each of those parts provides specific information about the whole domain name. 36 | 37 | [TLD](/en-US/docs/Glossary/TLD) (Top-Level Domain). 38 | 39 | TLDs tell users the general purpose of the service behind the domain name. The most generic TLDs (`.com`, `.org`, `.net`) don't require web services to meet any particular criteria, but some TLDs enforce stricter policies so it is clearer what their purpose is. For example: 40 | 41 | - Local TLDs such as `.us`, `.fr`, or `.se` can require the service to be provided in a given language or hosted in a certain country — they are supposed to indicate a resource in a particular language or country. 42 | - TLDs containing `.gov` are only allowed to be used by government departments. 43 | - The `.edu` TLD is only for use by educational and academic institutions. 44 | 45 | TLDs can contain special as well as latin characters. A TLD's maximum length is 63 characters, although most are around 2–3. 46 | 47 | The full list of TLDs is [maintained by ICANN](https://www.icann.org/resources/pages/tlds-2012-02-25-en). 48 | 49 | Label (or component) 50 | 51 | The labels are what follow the TLD. A label is a case-insensitive character sequence anywhere from one to sixty-three characters in length, containing only the letters A through Z, digits 0 through 9, and the - character (which may not be the first or last character in the label). `a`, `97`, and `hello-strange-person-16-how-are-you` are all examples of valid labels. 52 | 53 | The label located right before the TLD is also called a _Secondary Level Domain_ (SLD). 54 | 55 | A domain name can have many labels (or components). It is not mandatory nor necessary to have 3 labels to form a domain name. For instance, [www.inf.ed.ac.uk](http://www.inf.ed.ac.uk) is a valid domain name. For any domain you control (e.g. [mozilla.org](https://www.mozilla.org/en-US/)), you can create "subdomains" with different content located at each, like [developer.mozilla.org](https://developer.mozilla.org), [iot.mozilla.org](https://iot.mozilla.org/), or [bugzilla.mozilla.org](https://bugzilla.mozilla.org). 56 | 57 | ### [Buying a domain name](#buying-a-domain-name) 58 | 59 | #### Who owns a domain name? 60 | 61 | You cannot "buy a domain name". This is so that unused domain names eventually become available to use again by someone else. If every domain name was bought, the web would quickly fill up with unused domain names that were locked and couldn't be used by anyone. 62 | 63 | Instead, you pay for the right to use a domain name for one or more years. You can renew your right, and your renewal has priority over other people's applications. But you never own the domain name. 64 | 65 | Companies called registrars use domain name registries to keep track of technical and administrative information connecting you to your domain name. 66 | 67 | **Note:** For some domain name, it might not be a registrar which is in charge of keeping track. For instance, every domain name under `.fire` is managed by Amazon. 68 | 69 | #### Finding an available domain name 70 | 71 | To find out whether a given domain name is available, 72 | 73 | - Go to a domain name registrar's website. Most of them provide a "whois" service that tells you whether a domain name is available. 74 | - Alternatively, if you use a system with a built-in shell, type a `whois` command into it, as shown here for `mozilla.org`: 75 | 76 | > $ whois mozilla.org 77 | > Domain Name:MOZILLA.ORG 78 | > Domain ID: D1409563-LROR 79 | > Creation Date: `1998-01-24T05:00:00Z` 80 | > Updated Date: `2013-12-08T01:16:57Z` 81 | > Registry Expiry Date: `2015-01-23T05:00:00Z` 82 | > Sponsoring Registrar: MarkMonitor Inc. (R37-LROR) 83 | > Sponsoring Registrar IANA ID: 292 84 | > WHOIS Server: 85 | > Referral URL: 86 | > Domain Status: clientDeleteProhibited 87 | > Domain Status: clientTransferProhibited 88 | > Domain Status: clientUpdateProhibited 89 | > Registrant ID: mmr-33684 90 | > Registrant Name:DNS Admin Registrant Organization:Mozilla Foundation Registrant Street: 650 Castro St Ste 300 Registrant City:Mountain View Registrant State/Province:CA Registrant Postal Code:94041 Registrant Country:US Registrant Phone:+1.6509030800 91 | 92 | As you can see, I can't register `mozilla.org` because the Mozilla Foundation has already registered it. 93 | 94 | On the other hand, let's see if I could register `afunkydomainname.org`: 95 | 96 | > $ whois afunkydomainname.org 97 | > NOT FOUND 98 | 99 | As you can see, the domain does not exist in the `whois` database (at the time of writing), so we could ask to register it. Good to know! 100 | 101 | #### Getting a domain name 102 | 103 | The process is quite straightforward: 104 | 105 | 1. Go to a registrar's website. 106 | 2. Usually there is a prominent "Get a domain name" call to action. Click on it. 107 | 3. Fill out the form with all required details. Make sure especially that you have not misspelled your desired domain name. Once it's paid for, it's too late! 108 | 4. The registrar will let you know when the domain name is properly registered. Within a few hours, all DNS servers will have received your DNS information. 109 | 110 | **Note:** In this process the registrar asks you for your real-world address. Make sure you fill it properly, since in some countries registrars may be forced to close the domain if they cannot provide a valid address. 111 | 112 | #### DNS refreshing 113 | 114 | DNS databases are stored on every DNS server worldwide, and all these servers refer to a few special servers called "authoritative name servers" or "top-level DNS servers." — these are like the boss servers that manage the system. 115 | 116 | Whenever your registrar creates or updates any information for a given domain, the information must be refreshed in every DNS database. Each DNS server that knows about a given domain stores the information for some time before it is automatically invalidated and then refreshed (the DNS server queries an authoritative server and fetches the updated information from it). Thus, it takes some time for DNS servers that know about this domain name to get the up-to-date information. 117 | 118 | ### [Dns and How It Works?](#dns-and-how-it-works) 119 | 120 | If you want to get more details about [DNS](https://muratdemirci.github.io/backend-dev-roadmap/#/./internet/dns-and-how-it-works). 121 | -------------------------------------------------------------------------------- /internet/what-is-hosting.md: -------------------------------------------------------------------------------- 1 | # What is a Hosting? 2 | 3 | _© [itproportal](https://www.itproportal.com/features/what-is-web-hosting-what-you-need-to-know-to-choose-the-right-provider/) - By Ritoban Mukherjee, published October 25, 2021, all rights reserved_ 4 | 5 | # Contents 6 | 7 | 1. [Introduction](#introduction) 8 | 2. [What is web hosting?](#what-is-web-hosting) 9 | 3. [Web hosting: free or paid?](#web-hosting-free-or-paid) 10 | 4. [What are the different types of web hosting?](#what-are-the-different-types-of-web-hosting) 11 | 12 | ## [Introduction](#introduction) 13 | 14 | When you build a website, as well as using one of the best website builders, you'll also need to utilize the best web hosting(opens in new tab) for it to run smoothly online. But what is web hosting(opens in new tab)? 15 | 16 | Most businesses need an office; all websites need web hosting, as without it they can't be based on the internet. Web hosting is a service whereby you pay a web host, and they provide you with resources that you'll need to run your website on the internet. 17 | 18 | These resources depend on the type of hosting you go for, and the price you pay. You're given access to a certain amount, and it usually concerns storage space and network bandwidth, which are allocated on one or more physical servers in a data center owned by the web hosting provider of your choice. 19 | 20 | A wide variety of web hosting services are available, from free hosting all the way up to enterprise-level packages, and depending on the technical requirements of your site, and your own personal technical knowledge, you can pay for and use these to access adequate site resources for your website. 21 | 22 | ## [What is web hosting?](#what-is-web-hosting) 23 | 24 | When you build a website, as well as using one of the best website builders, you'll also need to utilize the best web hosting(opens in new tab) for it to run smoothly online. But what is web hosting(opens in new tab)? 25 | 26 | Most businesses need an office; all websites need web hosting, as without it they can't be based on the internet. Web hosting is a service whereby you pay a web host, and they provide you with resources that you'll need to run your website on the internet. 27 | 28 | These resources depend on the type of hosting you go for, and the price you pay. You're given access to a certain amount, and it usually concerns storage space and network bandwidth, which are allocated on one or more physical servers in a data center owned by the web hosting provider of your choice. 29 | 30 | A wide variety of web hosting services are available, from free hosting all the way up to enterprise-level packages, and depending on the technical requirements of your site, and your own personal technical knowledge, you can pay for and use these to access adequate site resources for your website. 31 | 32 | Below, we'll walk you through everything you need to know, so that you can then make the correct choice for your site's web hosting. 33 | 34 | What is web hosting? 35 | 36 | A website needs resources to stay online. These resources include such things as storage space for the site’s content, and network bandwidth to let visitors smoothly access it. While the storage makes sure that you have enough space to store all your site’s files, bandwidth is the capacity of data that can be transferred between the website and its users. 37 | 38 | The resources are obtained from a server—which is really just a powerful computer that’s connected to the internet at all times. Typically, a web hosting provider will have a large number of servers spread across one or more remote data centers. Depending on the plan you go for, the provider will allocate a set amount of resources on these servers for your website to use. 39 | 40 | ## [Web hosting: free or paid?](#web-hosting-free-or-paid) 41 | 42 | A question that a lot of budding website owners seem to ask is whether they should invest in a paid web hosting provider, or just choose a free one. Free web hosting services are indeed available, but they are limited in nature and often come with certain strings attached. 43 | 44 | Mostly, they are a way for a web hosting provider to advertise their more powerful paid hosting plans. For example, free web hosting will often limit the amount of storage space you can use or the number of visitors who can access your website in a given month. Services may even display intrusive advertisements on your website. 45 | 46 | These things can greatly impact the functioning of a professional site, which is why the best free web hosting(opens in new tab) is only recommended when you are working on a personal project with no financial implications. If, however, you are using your website for professional or business purposes, a paid hosting plan is a must-have. 47 | 48 | ## [What are the different types of web hosting?](#what-are-the-different-types-of-web-hosting) 49 | 50 | There are different types of web hosting services available in the market. They differ in aspects such as server speed, disk space, network bandwidth, and various secondary features. Depending on your specific circumstances, you can choose a plan with the resources that fit your needs and budget. Below are a few common forms of web hosting. 51 | 52 | Shared hosting: is a type of web hosting where a single server is shared by hundreds of websites. Because the servers are shared, their resources are divided between multiple websites, and result in lower server speed and higher response times. This is good for small websites, but established businesses and professionals will probably require something more powerful. 53 | 54 | VPS hosting: via a virtual private server (VPS), is a virtual section with set resources created within a physical server. Unlike shared hosting, each server is divided into only a few virtual servers and shared between five or 10 different websites. This reduces server load, and gives each website ample resources to function. Virtual servers are therefore costlier than shared servers. 55 | 56 | Dedicated hosting: is the most expensive form of web hosting, in which a single site takes up an entire server. This ensures that the maximum amount of resources are available at all times for exclusive use by the website. Dedicated hosting is only necessary for very large sites that boast a huge audience. 57 | 58 | Cloud hosting: is a new form of web hosting where a single site is hosted across multiple virtual servers, so it continues to function even when one server goes down. This ensures that your website is guaranteed maximum uptime. 59 | -------------------------------------------------------------------------------- /learn-a-programming-language/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/learn-a-programming-language/index.md -------------------------------------------------------------------------------- /learn-about-api-s/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/learn-about-api-s/index.md -------------------------------------------------------------------------------- /message-brokers/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/message-brokers/index.md -------------------------------------------------------------------------------- /os-general-knowledge/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/os-general-knowledge/index.md -------------------------------------------------------------------------------- /scaling/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/scaling/index.md -------------------------------------------------------------------------------- /search-engines/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/search-engines/index.md -------------------------------------------------------------------------------- /testing/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/testing/index.md -------------------------------------------------------------------------------- /version-control-systems/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/version-control-systems/index.md -------------------------------------------------------------------------------- /web-security/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/web-security/index.md -------------------------------------------------------------------------------- /web-servers/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/web-servers/index.md -------------------------------------------------------------------------------- /websockets/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratdemirci/backend-dev-roadmap/cf1d719fdd25dc22c8404d3ce2b676207b626441/websockets/index.md --------------------------------------------------------------------------------