Saturday, February 23, 2019

Kanban vs Scrum vs Agile: A Detailed Comparison to Find Differences


The Detailed Comparison of Kanban vs Scrum vs Agile
Do you want to complete your projects efficiently, in time? Are you stuck in a complex project? Circling around in a fast paced and ever changing environment? Did someone tell you to follow an agile methodology to end all these hiccups?
When it comes to an agile methodology, different people have different sets of opinions. Some say, Kanban; some say, Scrum. There you go! Another confusion.
Well, this post is to eliminate the confusion.
Comparison of Kanban Scrum and Agile

What is Kanban?

  • To start, Kanban means ‘Visual Signal’ in Japanese. Kanban process is all about visualizing what you are doing today.
  • Kanban process is nothing but a Board, named as the “Kanban Board” which not only plays a significant role in displaying the workflow but also helps to optimize the flow of task between different teams.
  • Now, there are companies which follow physical boards and there are ones which follow the virtual boards. The latter comes in handy in terms of availability and accessibility in terms of locations.
  • Kanban boards basically have three segments; To Do, In Progress and Done.
What is Kanban
  • However, depending on the project, team size, workflow Kanban board can be mapped accordingly. The board can have modified segments such as; to do, In Progress, Code review, In Testing, Deliverable etc.
  • Every work item on the board is a Kanban Card. The only aim of using a Card [Physical/Virtual] is to make the team able enough to track the work visually.
  • Cards give a brief idea on the particular work item, responsibility, estimated completion, and the current status of the work item.
  • This enables the team to foresee the challenges, faster capture of Blockers, increases the traceability, reducing of the dependencies.
  • In this process, the team is only involved in the work item that is in progress. Only when the work item is moved to DONE state, they pick the next work item from the Backlog/to do list.
  • The most important work items are kept at the top of the ‘to-do’ list by the product owner. There can be reshuffling done to the priority if needed.
  • There are no fixed length iterations followed in Kanban. It is all based on the cycle times. Cycle time is the time that is needed to move a work item from To Do state through ‘done’ state.
  • Kanban also gives importance on overlapping skill sets. When a resource has multiple skill sets, she/he doesn’t have to work on a specific skill set all the time. She/he can contribute to the work item in multiple dimensions. For e.g. a developer does not have to stick to development always. In cases of requirement, he can switch to Testing which would ultimately reduce the dependencies and hence the cycle time.

What is Scrum?

what is scrum framework
  • Like Kanban, Scrum is another framework for implementing Agile. Scrum is unique in having characters such as; defined iteration durations, role based tracking/approach etc.
  • Scrum follows a set of fixed length iterations in which the product is developed. Each of these iterations are called as Sprint. Typically, each sprint is fixed somewhere within 2 weeks to 1 month.
  • The start of each Sprint happens with a Sprint Planning meeting which finalizes the backlog/work items planned for that sprint. An estimation of the Sprint is also declared/justified in this phase.
    • Selection of Product Backlog for the specific Sprint is done in this phase.
    • Communicate to all the involved people about the scope and completion targets.
    • Backlog items can also be split when needed.
    • Priorities can be modified on the backlog items in this phase and a call is taken based on it.
  • Each Sprint goes on with Daily stand-Up meetings/Daily Scrum meetings
    • Each team member joins this meeting
    • This does not exceed 15 minutes.
    • What has been done since the last meeting, What is to be done before the next Scrum meeting is discussed during these meetings
    • Blockers, Bottlenecks, dependencies if any are brought to the notice in these meetings.
  • Each Sprint is concluded with the Retrospective meeting
    • Completed work items are showcased/ Demo is given on the work items
    • Two things are analyzed: Success points in the Sprint and the improvement area for the next Sprint.
  • Once the Sprint is over, the same steps repeat for the remaining Backlog items.
  • Scrum is basically operated based on the roles. Three roles to be precise; The Product Owner, Scrum master, and the Development team
    • The Product Owner: They are the ones who know about the Product. List of Backlogs is put together by them. They study the real business and make sure the product deliverables are best suited to address the business needs.
    • The Scrum Master: They are the hounds who live on the delivery flow, sprint planning, reviews, Daily meetings etc.
    • The Development team: They work towards delivering a shippable product at the end of the Sprint. This team does the work such as; analyzing, designing, developing, testing, documenting etc.
Now that we know what Kanban and Scrum individually, we can proceed to the comparison/versus question.

Kanban Vs Scrum

As we have seen in the above descriptions, both of them share the same [mostly same] ideology. But the way the things are done in both of these processes is very different.
ScrumKanban
The iterations/Sprints are fixed in duration. That normally varies from 2 weeks to 1 month.This does not work on the duration. This is measured in terms of Cycle times.
Team basically estimates or plans each sprint based on the Backlog sheet.This is tracked in terms of the Workflow/Work item/Kanban card
This process floats on the basis of three roles;
The Product Owner
The scrum master 
And the Development
This doesn’t work on the basis of roles.
No changes are allowed once the Sprint has startedThis is flexible here. Changes are allowed at any moment
As Sprint is done in batches, the total work is done/achieved in batches/SprintsWork is done based on the movement of single threaded work item flows
Some companies/teams choose Scrum where others chose Kanban. Sometimes, both are combined together which is hailed as Scrumban. The best of the both are chosen in Scrumban.
For e.g. Fixed lengths Sprint cycles and roles from Scrum with the focus on work in progress limits and cycle time from Kanban. All I am saying is, both are robust in their own way and can also be tweaked/combined together if needed. It is all up to the team/company/requirement.
Now, how about Scrum vs Agile?

What is the difference between Scrum and Agile?

Wondering about the differences between Scrum vs Agile or Agile vs Scrum is like seeking for the differences between the words “Red” and “Color”. Red is a  type of color and use of it depends on the specific taste and comfort level of their users. The same could be said about Scrum vs Agile.
Scrum is a type of agile methodology. It is essentially an agile process framework. In fact, Scrum and Kanban in software development terms are both specific flavors or types of an agile software methodology.
While we can compare Scrum vs Kanban or Kanban vs Scrum  (just like we can compare the colors “Red” and “Blue”) as we’d be comparing two agile methodologies, however comparing Scrum vs Agile would be like comparing the words “Red” and “Color”.
Scrum is just one of the many iterative and incremental agile software development method. You can find here a very detailed description of the process.

Conclusion

There is a significant difference between Kanban and Scrum agile methodologies. Hope we are able to explain the difference in simple words.
About the author: Subhasis has over 8 years of corporate experience working for Fortune 500 IT companies in the field of Software Quality Assurance, Software Development and Testing experience. He currently heads the QA team of a top-tier IT company and loves to write about his experiences on Software Testing Tricks and here on Software Testing Help.
 
 

Thursday, January 31, 2019

Understanding and Using SQL Server sys.dm_exec_requests

Problem
I know SQL Server has a lot of views and functions which I can use to understand what’s going on with my SQL Server. I’m interested in seeing what SQL Server can tell me about the active requests from connected users and applications. How can I see this information?
Solution
The SQL Server dynamic management view (DMV) you’ll want to use is sys.dm_exec_requests. However, it doesn’t just show us the requests being made from connected users and applications. For instance, we can see that SQL Server has a lot of background tasks, too, using a simple query:
SELECT session_id, start_time, command
FROM sys.dm_exec_requests
WHERE status = 'background';   
This is a small sample. The actual query returned over 20 different sessions on my test system.
sys.dm_exec_requests output
Typically, though, we’ll use this DMV to troubleshoot active sessions. One of the easiest things to look at is who is experiencing waits:
SELECT session_id, blocking_session_id, start_time, wait_type, wait_type
FROM sys.dm_exec_requests
WHERE blocking_session_id > 0;   
And here we see that one session is blocking another. The wait type also tells us what type of lock:
sys.dm_exec_requests output
We can determine what the query is/was that has caused the blocking by one of two means:
  1. If it has an active request, we use sys.dm_exec_requests and sys.dm_exec_sql_text() to pass the sql_handle in.
  2. If it does not have an active request, we join to sys.dm_exec_connections and pass the most_recent_sql_handle to sys.dm_exec_sql_text().
In this case, I know there’s no active request because I’ve queried sys.dm_exec_requests for session id 53. Therefore, I’ll drop back to the second option:
SELECT DISTINCT DEC.session_id, DST.text AS 'SQL'
FROM sys.dm_exec_requests AS DER
  JOIN sys.dm_exec_connections AS DEC
    ON DER.blocking_session_id = DEC.session_id
  CROSS APPLY sys.dm_exec_sql_text(DEC.most_recent_sql_handle) AS DST;   
And we see that the following query is returned:
sys.dm_exec_requests output
This seems like an innocuous query, a simple insert, so there’s more going on. In this case, it’d be nice to see if there’s a open transaction. If it had an active request, we could look at the open_transaction_count in sys.dm_exec_requests. Since this one does not have an active request, we can check sys.dm_exec_sessions:
SELECT session_id, open_transaction_count
FROM sys.dm_exec_sessions
WHERE open_transaction_count > 0;   
And we’ll see that there is an open transaction. So it looks like someone forgot to COMMIT.
sys.dm_exec_requests output

Getting the Active SQL Server Plan

If I have a long running query, I may want to see the plan for that query to determine why it’s taking forever. Perhaps the plan is terrible. This query returns the plans for any active queries:
SELECT DER.session_id, DEQP.query_plan 
FROM sys.dm_exec_requests AS DER
  CROSS APPLY sys.dm_exec_query_plan(DER.plan_handle) AS DEQP
WHERE NOT DER.status IN ('background', 'sleeping');   
And here we see that we have two active queries with plans:
sys.dm_exec_requests output
In this case, I know that I ran my query from session 52. Therefore, I want to look at session 53. If I’m using SQL Server Management Studio I can simply click on the XML under query plan to view it graphically.
sql server query plan

Get Percent Complete for Active SQL Server Query

One of the nice things that we can find in sys.dm_exec_requests is the percent complete column. For instance, if I want to see how far along a DBCC check is, I could do a simple query where I filter based on the command. In this case I know it’s DBCC TABLE CHECK, so that’s what is in my where clause:
SELECT session_id, start_time, status, database_id,percent_complete 
FROM sys.dm_exec_requests
WHERE command = 'DBCC TABLE CHECK';   
And we see that we’re about 11% complete:
sys.dm_exec_requests output
This obviously can be used to check any long running query.

Get All Active SQL Server Requests to a Particular Database

A lot of times we want to see what all is acting against a particular database. We can use sys.dm_exec_requests for this as well. In this case we’ll want to join to sys.databases in order to filter based on a name. If you know the database ID already, you won’t need to do this join. There is a function DB_ID() which you can use in the WHERE clause to translate a name into the database ID, which you can as well. Also, since I do want to know who is connected and how they’re connected (what application), I’m going to join back to sys.dm_exec_sessions as well. Here’s the query, which filters based on the database named Test.
SELECT DER.session_id, DES.login_name, DES.program_name
FROM sys.dm_exec_requests AS DER
  JOIN sys.databases AS DB
    ON DER.database_id = DB.database_id
  JOIN sys.dm_exec_sessions AS DES
    ON DER.session_id = DES.session_id
WHERE DB.name = 'Test';   
And when we run the query, we find there are two active sessions:
sys.dm_exec_requests output
Since this is against the sys.dm_exec_requests DMV, we know these are active requests against the Test database. If we are trying to troubleshoot performance problems against a specific database, this is a good place to start. Obviously, we can combine this query with a previous one to get the actual queries being run as well as the execution plans.

Seeing a Count of All Active SQL Server Wait Types

Sometimes we’re trying to diagnose a problem and we want to know if we’re seeing a large number of wait types occurring. We can do this using sys.dm_exec_requests because the current wait type being experienced is presented. Therefore, if we filter out any background or sleeping tasks, we can get a picture of what the waits are for active requests and we can also see if we have a problem. Here’s the query:
SELECT COALESCE(wait_type, 'None') AS wait_type, COUNT(*) AS Total
FROM sys.dm_exec_requests
WHERE NOT status IN ('Background', 'Sleeping')
GROUP BY wait_type 
ORDER BY Total DESC;   
Here is an example of the query output:
sys.dm_exec_requests output
We see that we have two LCK_M_S wait types. This is the wait type we get when we have requests waiting on obtaining a shared lock. We can then query along with sys.dm_tran_locks to determine what types of locks these active requests were trying to obtain:
SELECT L.request_session_id, L.resource_type, 
  L.resource_subtype, L.request_mode, L.request_type 
FROM sys.dm_tran_locks AS L
  JOIN sys.dm_exec_requests AS DER
    ON L.request_session_id = DER.session_id
WHERE DER.wait_type = 'LCK_M_S';   
And here we see the full list for the two session IDs:
sys.dm_exec_requests output
There’s more that we can do on the troubleshooting side, but this should give you an idea of the power of sys.dm_exec_requests.