You are on page 1of 9

What is Scalability?

Scalability is the capability of the system, process, application or


network to handle a growing amount of work, or system’s potential to
expand itself in order to handle that growth.

Scalability is viewed from two different angles: (1) machines — how the
system behaves when the system usage increases and (2) humans -
how the system behaves when the development team grows.

Machine Scalability — Performance and Speed

In most cases, scalability is viewed as how much load system can bear
at a time (machine scalability). In that sense, Python is less scalable in
terms of performance and execution speed than other programming
languages like Java and C++ because of several reasons discussed
below.

Scripting Language — Slower

One reason for Python being slower is that it is a scripting language.


Most scripting languages usually perform slower than programming
languages. So does Python.
Unlike programming languages like C and C++, with which the source
code is compiled directly into machine code, Python is simply plain
text, which requires being interpreted at run time. With Python, each
code line may require some hundreds of programming instructions to
execute, in a dual stack, recursive descent parsing algorithm.
No Multithreading Support

Multi-threading in Python is not robust at all

As mentioned above, scalability means the system’s capability to


handle a growing amount of work, in other words, an increasing
number of requests. Now, one technique which is really useful to make
applications scalable is multithreading. Multithreading is the
technique in which we divide program or process into multiple threads
which run concurrently, hence providing a significant amount of speed
in the applications.
Programming languages like Java offer much more robust support for
multithreading than Python. This is because Python uses GIL (Global
Interpreter Lock) which prevents Python interpreter to perform
multiple tasks concurrently (means doing multitasking) and enforces it
to run only a single thread at a time. Python language has its own
reasons to use GIL but it does impact on the performance of the
application. This multithreading support is also the reason why Java is
more popular in enterprise applications as compared to Python.

Human Scalability

Another side of the scalability is human, which is about the situation


when the development team grows in size or when the number of code
changes done by developers in a system. If we compare Java to Python,
then Java’s static typing comes in handy while scaling the system in
terms of adding more features (lines of code). As Java is a more
verbose language with strict rules of coding and also consists of a type
safety system which produces fewer errors at runtime, Java allows the
system development to grow at high scale smoothly (in terms of lines
of code).

Python, on the other hand, is a dynamically-typed language. This


feature does not suit well when the team grows or the lines of code
increase significantly, as developers find more runtime errors. The
system, therefore, becomes complex and hard to maintain at a high
scale.
How To Overcome Scalability Limitations in Python

After knowing all of the above scalability issues found in Python, you
would be wondering why should you pick Python language for your
project as it has several scalability issues, or why Python is still used by
many large companies in large projects. It’s because there are several
solutions to these limitation issues.

Using Python Implementations

Using Python with C-like performance is totally possible. This goal can
be achieved with CPython, which is a superset of Python and also
includes some features of C, in which Python code is written.

Another well-known Python implementation is Jython, which is


designed to compile Python code to Java bytecode. Thanks to this
implementation, we can take advantages of Java virtual machine and
Java libraries. Thus, Python can have the same scalability and
performance boost as Java.

Horizontal & Vertical Scaling

We can solve the problem of scalability in terms of handling the


growing amount of work by performing horizontal and vertical scaling
properly, which is done at the hardware level.

This particular process of scaling has two types: vertical scaling and
horizontal scaling. Vertical scaling is the process of adding more
memory, disk space, and CPUs to the single machine. Though vertical
scaling will eventually hit its limits depending on the machine or server
that how much it can support. In that case, we should apply horizontal
scaling which is the process of adding entire machines or servers to the
system in order for it to handle more throughput.

Better architecture

Essentially, scalability is not the problem within the language itself but
it depends on (in some aspects) decisions taken at the design and
architectural level in the development process. The architecture should
be designed in such a way that it has the flexibility to grow or scale.
Many optimizations can be done in the early phase of the projects. For
example, Nginx for static and apache for dynamic content, using CDN
for static content, Proper use of vertical and horizontal scaling, and
Load balancers and auto-scaling features.

Does Scalability Only Thing That Matters?

Scalability is surely the main factor which should be considered when


developing large applications. But, there are several important factors
which should be taken into account like programming language
productivity, ease of use, ecosystem, support, and tools.

Regarding productivity, Python is slower in terms of performance and


speed but it provides much flexibility and requires very fewer lines of
code for same tasks that require much more lines of code in other
languages like Java. So, Python allows developers to develop
applications more quickly.

Additionally, Python language is very easy to learn and use as


compared to languages like Java which require a significant amount of
time to learn in order to be used effectively in application development.

Final Thoughts

Python does have scalability limitations. However, it is still used in


many famous projects, such as Youtube, Pinterest, Reddit, Dropbox,
and Quora were built on it. As every programming language has its
own advantages and disadvantages. It depends on us that which
language we choose that overall suits our needs.

To cope with the scalability limitations of Python, there are several


solutions:

 Using Python implementations such as CPython or Jython to


reach C-like performance and take advantages of Java;
 Using proper horizontal and vertical scaling;
 Thoroughly plan the project from the initial phase and ensure
that the architecture is scalable.

460
Scripting language v/s Programming language
The first question which strikes into the mind is, what is the difference between programming
and scripting language. The only difference which exists is that the scripting language does not
require any compilation, it is directly interpreted.
For example, the programs written in a language such as C++ are compiled before execution
whereas the programs written in scripting languages such as Python or JavaScript are directly
interpreted and are not compiled.

Why is Python a scripting language?


A scripting language is one that is interpreted. Python is an interpreted language. Python uses an
interpreter to translate and run its code. Hence Python is a scripting language.

Interpreter v/s Compiler


Compiler − Compiler scans the whole program at once and converts it into machine code.
Interpreter − The interpreter converts the program into machine code one line at a time.
The languages which use interpreter are scripting languages, which include Python, JavaScript
etc.

Why Python is called Dynamically Typed?


Python is a dynamically typed language. What is dynamic? We don't have to declare the type of
a variable or manage the memory while assigning a value to a variable in Python. Other
languages like C, C++, Java, etc.., there is a strict declaration of variables before assigning
values to them. We have to declare the kind of variable before assigning a value to it in the
languages C, C++, Java, etc..,
Python don't have any problem even if we don't declare the type of variable. It states the kind of
variable in the runtime of the program. Python also take cares of the memory management
which is crucial in programming. So, Python is a dynamically typed language. Let's see one
example.

Example
 Live Demo

## assigning a value to a variable


x = [1, 2, 3]

## x is a list here
print(type(x))

## reassigning a value to the 'x'


x = True

## x is a bool here
print(type(x))
## we can also redefine 'x' as many times as we want

Output
If you run the above program, it will generate the following results.
<class 'list'>
<class 'bool'>

You might also like