What happens when we type a URL in the browser (In Depth)?

jogendra@.net

If you are reading this then i would recommend to read this  article first for a clear visibility that what we will understand in depth 🙂

https://jogendras.wordpress.com/2017/07/17/what-happens-when-we-type-a-url-in-the-browser/

Have you ever wondered, precisely – 

  • What happens in the background when we type a URL in the browser?
  • How does a web page life-cycle sequence work?
  • How browser knows, where to send request for the requested page?
  • What happens on the Web Server when a request for a web page comes in?
  • How does the Web server handle the incoming request?
  • How is the HTML that is emitted to the client generated?
  • How browser renders the page on the screen?
  • Etc…

If you are also looking answers of above mentioned questions then this article is definitely for you. In this article, we will take a deeper look at the sequence of events that take place when we visit a ASP.NET page URL –

  1. URL is…

View original post 622 more words

Advertisements

What Is REST API?

REST is an architectural style which stands for Representational State Transfer.

An API for a website is that allows two software programs to communicate with each another. A REST-Ful API is an application program interface that uses HTTP requests to GET, PUT, POST and DELETE data. REST is a logical choice for building APIs that allow users to connect and interact with cloud services. RESTful APIs are used by such sites as Amazon, Google, LinkedIn and Twitter.

A RESTful API explicitly takes advantage of HTTP methodologies defined by the RFC 2616 protocol. They use GET to retrieve a resource; PUT to change the state of or update a resource, which can be an object, file or block; POST to create that resource; and DELETE to remove it.

Why REST ?

REST systems aim for –

  • Fast performance –  component interactions can be the dominant factor in user-perceived performance and network efficiency
  • Reliability – is the resistance to failure at the system level in the presence of failures within components, connectors, or data
  • Scalability – ability to grow, by re-using components that can be managed and updated without affecting the system as a whole, even while it is running.
  • Simplicity of a uniform Interface
  • Visibility of communication between components by service agents

The REST architectural style describes six constraints. These constraints, applied to the architecture, were originally communicated by Roy Fielding in his doctoral dissertation in 2000 and defines the basis of RESTful-style. If a service violates any of the required constraints, it cannot be considered RESTful.

The formal REST constraints are as follows:

  1. Client-Server–  The client-server constraint works on the concept that the client and the server should be separate from each other and allowed to evolve individually and independently. In other words, I should be able to make changes to my mobile application without impacting either the data structure or the database design on the server. At the same time, I should be able to modify the database or make changes to my server application without impacting the mobile client. This creates a separation of concerns, letting each application grow and scale independently of the other and allowing your organization to grow quickly and efficiently.
  2. Stateless :Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client.
  3. Cacheable : – Cache constraints require that the data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests.
  4. Uniform interface: – The uniform interface lets the client talk to the server in a single language, independent of the architectural backend of either. This interface should provide an unchanging, standardized means of communicating between the client and the server, such as using HTTP with URI resources, CRUD (Create, Read, Update, Delete), and JSON.
  5. Layered system: As the name implies, a layered system is a system comprised of layers, with each layer having a specific functionality and responsibility. If we think of a Model View Controller framework, each layer has its own responsibilities, with the models comprising how the data should be formed, the controller focusing on the incoming actions and the view focusing on the output. Each layer is separate but also interacts with the other. In REST API design, the same principle holds true, with different layers of the architecture working together to build a hierarchy that helps create a more scalable and modular application.
  6. Code on demand (optional) : Perhaps the least known of the six constraints, and the only optional constraint, Code on Demand allows for code or applets to be transmitted via the API for use within the application. In essence, it creates a smart application that is no longer solely dependent on its own code structure. However, perhaps because it’s ahead of its time, Code on Demand has struggled for adoption as Web APIs are consumed across multiple languages and the transmission of code raises security questions and concerns. (For example, the directory would have to be writeable, and the firewall would have to let what may normally be restricted content through.)

 

REFERENCES-

https://www.mulesoft.com/resources/api/what-is-rest-api-design

https://restfulapi.net/

SQL SERVER : JOINS

jogendra@.net

SQL Server : JOINS are used to retrieve data from multiple tables. A SQL Server JOIN is performed whenever two or more tables are joined in a SQL statement.

There are 4 different types of SQL Server joins:

1) INNER JOIN                       -or-              SIMPLE JOIN
2) LEFT JOIN                        -or-              LEFT OUTER JOIN
3) RIGHT JOIN                       -or-              RIGHT OUTER JOIN
4) FULL JOIN      -or-              FULL OUTER JOIN
5) SELF JOIN
6) CROSS JOIN

INNER JOIN:-   INNER JOINS return all rows from multiple tables where the join condition is met.

INNER JOIN would return the…

View original post 552 more words

What happens when we type a URL in the browser?

jogendra@.net

If you are curious to know what happens in the background when we type a URL in the browser then this article is definitely for you. Below are the sequence of events that occurs when we enter a URL in the browser’s address bar-

  1. You type the URL into address bar in your preferred browser
  2. The browser parses the URL to find the protocol, host, port, and path.
  3. Browser checks cache, if requested object is in cache and is fresh, skip to #15
  4. Browser asks OS for entered domain’s IP address
  5. OS makes a DNS lookup and replies the IP address to the browser
  6. Browser opens a TCP connection to the server
  7. When a connection is open, browser sends the HTTP request to the host
  8. The host forwards the request to the server software (most often Apache, IIS) configured to listen on the specified port
  9. Server handles the…

View original post 293 more words

What is CSS Flexbox and how to use it?

Before the CSS Flexbox Layout module, there were four layout modes:

  1. Block, for sections in a web page
  2. Inline, for text
  3. Table, for two-dimensional table data
  4. Positioned, for explicit position of an element
  • CSS Flexbox is a whole module and not a single CSS property, it involves a set of properties.
  • Some of them are meant to be set on the container (parent element, known as “flex container”) whereas the others are meant to be set on the children (said “flex items”).
  • The Flexbox Layout module aims at providing a more efficient way to lay out, align and distribute space among items in a container.
  • The main idea behind the flex layout is to give the container the ability to alter its item’s width/height (and order) to best fill the available space
  • A flex container expands items to fill available free space, or shrinks them to prevent overflow.
  • Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based).

 

Working with Flexbox-

  • When working with flexbox we need to think in terms of two axes — the main axis and the cross axis. The main axis is defined by the flex-direction property, and the cross axis runs perpendicular to it.
  • Items will be laid out either the main axis (from main-start to main-end) or the cross axis (from cross-start to cross-end).flex-axis

Properties for the Parent (flex container):

  • display: flex | inline-flex; – Allows us to create a flex container (a flex context for all its direct children),
    • flex-demo-1
  • flex-direction : row | row-reverse | column | column-reverse – Allows us to change the direction in which our flex items display. default is row.
    • flex-demo-direction
  • flex-wrap: nowrap | wrap | wrap-reverse; – Specifies whether the flex items should wrap or not. nowrap is default.
    • nowrap (default): all flex items will be on one line
    • wrap: flex items will wrap onto multiple lines, from top to bottom.
    • wrap-reverse: flex items will wrap onto multiple lines from bottom to top.
    • flex-demo-wrap.png
  • flex-flow: <‘flex-direction’> || <‘flex-wrap’> : is a shorthand property for setting both the flex-direction and flex-wrap properties.
  • justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly; : This defines the alignment along the main axis. It helps distribute extra free space left over when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size.
    • flex-start (default): items are packed toward the start line
    • flex-end: items are packed toward to end line
    • center: items are centered along the line
    • space-between: items are evenly distributed in the line; first item is on the start line, last item on the end line
    • space-around: items are evenly distributed in the line with equal space around them. Note that visually the spaces aren’t equal, since all the items have equal space on both sides. The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies.
    • space-evenly: items are distributed so that the spacing between any two items (and the space to the edges) is equal.
    • flex-demo-js.png
  • align-items: stretch | flex-start | flex-end | center | baseline; – property is used to align the flex items vertically.
    • stretch (default): stretch to fill the container (still respect min-width/max-width)
    • flex-start: cross-start margin edge of the items is placed on the cross-start line
    • flex-end: cross-end margin edge of the items is placed on the cross-end line
    • center: items are centered in the cross-axis
    • baseline: items are aligned such as their baselines align
    • flex-demo-ai.png
  • align-content: flex-start | flex-end | center | space-between | space-around | stretch; This aligns a flex container’s lines within when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main-axis
    • flex-demo-ac.png

 

Properties for the Children (flex items):

 

  • order: <integer>; By default, flex items are laid out in the source order. However, the order property controls the order in which they appear in the flex container.
    • flex-demo-order.png
  • flex-grow: <number>/* default 0 */; property specifies how much a flex item will grow relative to the rest of the flex items. If all items have flex-grow set to 1, the remaining space in the container will be distributed equally to all children. If one of the children has a value of 2, the remaining space would take up twice as much space as the others 
    • flex-demo-grow.png
  • flex-shrink: <number>; /* default 1 */ – property specifies how much a flex item will shrink relative to the rest of the flex items.
  • flex-basis: <length> | auto; /* default auto */ – 
    • flex-demo-basis.png
  • flex: none | [ <‘flex-grow’> <‘flex-shrink’>? || <‘flex-basis’> ] – is a shorthand property for the flex-grow, flex-shrink, and flex-basis properties
  • align-self: auto | flex-start | flex-end | center | baseline | stretch; flex-demo-align-self.png

 

References-

https://www.w3schools.com/css/css3_flexbox.asp#flex-flow

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox

 

How can a single core processor run multiple tasks at once?

If you are reading this article then may be you are looking for some answers of questions like below-

  • How can a single core processor run multiple tasks at once?
  • How does multi-threading work in a single-core computer?
  • How does a single thread run on multiple cores?
  • Can a single core of a CPU process more than one process?
  • Multiple CPUs, Cores, and Hyper-Threading, Multitasking, Multiprocessing etc…

Or, If a computer having single core processor can run only one task at a time then how we are able to do multiple things like editing documents, hearing music, scanning computer etc… simultaneously without any interruption?

On a single-processor multitasking system, multiple processes don’t actually run at the same time since there’s only one processor. Instead, the processor switches among the processes that are active at any given time. Because computers are so fast compared with people, it appears to the user as though the computer is executing all of the tasks at once.

multitask20on20single20core_550

Multitasking on a multiple-processor system still involves the processors switching between tasks because there are almost always more tasks to run than there are processors. Note, however, that there can be as many tasks running simultaneously as there are processors in the system. Multitasking OSs can truly execute multiple tasks concurrently. The multiple computing engines work independently on different tasks.

multitask20on20multiple20cores_550

So to make a single core able to run multiple threads, a form of time-division multiplexing was used. To simplify things a bit: the OS sets up a timer which interrupts the system at a fixed interval. A single interval is known as a time slice. Everytime this interrupt occurs, the OS runs the scheduling routine, which picks the next thread that is due to be executed. The context of the core is then switched from the currently running thread to the new thread, and execution continues.

Since these timeslices are usually very short, as a user you generally don’t even notice the switches. For example, if you play an mp3 file, the CPU has to decode the audio in small blocks, and send them to the sound card. The sound card will signal when it is done playing, and this will trigger the mp3 player to load new blocks from the mp3 file, decode them, and send them to the sound card. However, even a single-core CPU has no problem playing an mp3 in the background while you continue work in other applications. Your music will not skip, and your applications will run about as well as when no music is playing. On a modern system that is no surprise, as playing an mp3 takes < 1% CPU time, so its impact is negligible.

Multitasking :  A task generally refers to a single application/process. So multitasking means you are using multiple applications at the same time. Multitasking contrasts with single-tasking, where one process must entirely finish before another can begin. MS-DOS is primarily a single-tasking environment, while Windows XP or later OS are multi-tasking environments.

So, Multitasking refers to the ability of the OS to quickly switch between each computing task to give the impression the different applications are executing multiple actions simultaneously.

Multithreading: Multithreading extends the idea of multitasking into applications, so you can subdivide specific operations within a single application into individual threads. Each of the threads can run in parallel. The OS divides processing time not only among different applications, but also among each thread within an application. Multithreading provides a way to have more than one thread executing in the same process while allowing every thread access to the same memory address space. This allows very fast communication among threads.

Hyper-Threading: A single physical CPU core with hyper-threading appears as two logical CPUs to an operating system. The CPU is still a single CPU, so it’s a little bit of a cheat. While the operating system sees two CPUs for each core, the actual CPU hardware only has a single set of execution resources for each core. In other words, the operating system is tricked into seeing two CPUs for each actual CPU core. Hyper-threading allows the two logical CPU cores to share physical execution resources. This can speed things up somewhat—if one virtual CPU is stalled and waiting, the other virtual CPU can borrow its execution resources. Hyper-threading can help speed your system up, but it’s nowhere near as good as having actual additional cores.

Multiple Cores: Originally, CPUs had a single core. That meant the physical CPU had a single central processing unit on it. To increase performance, manufacturers add additional “cores,” or central processing units. A dual-core CPU has two central processing units, so it appears to the operating system as two CPUs. A CPU with two cores, for example, could run two different processes at the same time. This speeds up your system, because your computer can do multiple things at once.

cores

Unlike hyper-threading, there are no tricks here — a dual-core CPU literally has two central processing units on the CPU chip. A quad-core CPU has four central processing units, an octa-core CPU has eight central processing units, and so on.

Multiple CPUs: Systems with multiple CPUs aren’t very common among home-user PCs today. Even a high-powered gaming desktop with multiple graphics cards will generally only have a single CPU. You’ll find multiple CPU systems among supercomputers, servers, and similar high-end systems that need as much number-crunching power as they can get.

 

References-

https://technet.microsoft.com/en-us/library/cc767883.aspx

https://scalibq.wordpress.com/2012/06/01/multi-core-and-multi-threading/

https://www.howtogeek.com/194756/cpu-basics-multiple-cpus-cores-and-hyper-threading-explained/